Is there a guide for bringing Ash into an existing phx.gen.auth app?
I've seen a few posts about this in the past but nothing recently. It may be as simple as creating a User resource that matches the Ecto schema and turning automatic migrations off? But then how do I get current_user into the scope/context so that all of the policy stuff works great? Trying to gauge if it's more effort to attempt this or to replace all of the auth (including UI) with AshAuthenticationPhoenix.
3 Replies
@yyy66133 you can create a plug that turns your ecto user into an Ash user (no need to revisit the db for this), but its not really necessary, up to you. You can then use
Ash.PlugHelpers.set_user
to set the user for any API extensions in use. For your UI though, you just pass the user or scope down, and pass it to the relevant actions.
if you're using scopes, check out the docs at Ash.Scope
Thanks so much!