Use magic_link for both invitations and sign-in
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
2. Have a
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
1. Create a
create action on my user resource which is limited to actor_attribute_equals(:role, :admin), and 2. Have a
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 resource? In that case, would it still be possible to use the ash_auth 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.
