I'd like to use the magic_link authentication strategy to both invite users, and to let existing users log in. My thinking is that in order to do that, I'll
1. Create a
create
create
action on my user resource which is limited to
actor_attribute_equals(:role, :admin)
actor_attribute_equals(:role, :admin)
, and 2. Have a
read
read
action for the sign in logic.
To do this, the e-mail would have to look a little different though, and I think it makes sense to have an invitation token be valid for longer than a login token. I haven't figured out how to do either.
As a final question, does this approach make sense, or would it be better to e.g. create a separate
Invitation
Invitation
resource? In that case, would it still be possible to use the ash_auth
Token
Token
somewhow?
Solution
Okay so I think the way to do it would be to have two separate magic link strategies on the resource - one for sign in and one for invites. The invite one can have a longer token lifetime. When your admin is inviting someone you can trigger the request action for the invite in an after action hook.
The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.