AshAuthentication Testing
Need help setting up a function that mocks a logged in user in my conn.
I'm using magic link authentication, this is what I've got so far:
What's the correct way to go about this? Am I placing the wrong key in the session maybe? Does Ash have any helpers for this?
Solution:Jump to solution
```elixir
def log_in_user(conn, user) do
strategy = AshAuthentication.Info.strategy!(MyApp.Accounts.User, :magic_link)
{:ok, token} = AshAuthentication.Strategy.MagicLink.request_token_for(strategy, user)
user = Accounts.sign_in_with_magic_link!(%{token: token}, authorize?: false)...
4 Replies
I think something like that is the conventional way
We've talked about having test helpers for it but no one has PRd anything yet 🥲
Oh. The thing is, it is not working 😅
How does Ash load the user from the session?
Figured it out
Solution
In case anyone needs it