Any pointers on testing authenticated LV's with AshAuthentication Magic Link?
I'm attempting to reproduce a similar workflow to the email/password instructions in the docs but am running into issues around confirmation add ons when combined with magic link authentication.
My current setup looks like this, but is erroring with a
Fails with AshAuthentication.Errors.CannotConfirmUnconfirmedUser
:
Any guidance would be much appreciated!GitHub
ash_authentication/documentation/topics/testing.md at main · team-...
The Ash Authentication framework. Contribute to team-alembic/ash_authentication development by creating an account on GitHub.
7 Replies
Is this happening in a specific test? Do you have a stack trace?
This is being set up in
conn_case.ex
so the suite that pulls in register_and_log_in_user
inside the setup
block fails before getting to any assertions
Stack trace fyr:
Ok I think I have a work around, if I set the confirmed_at
manually to DateTime.utc_now()
or a valid timestamp the errors went awayFrom the error message I assume you have configured the confirmation addon and you are hitting this line https://github.com/team-alembic/ash_authentication/blob/e8dcae5d182b21b3ac8ff11b3af3495e69d34bd0/lib/ash_authentication/add_ons/confirmation/confirmation_hook_change.ex#L191
You can probably add a date in the seed to make it pass, but it might make sense to take a step back and look at what exactly you have configured. Are you only using magic link sign in?
GitHub
ash_authentication/lib/ash_authentication/add_ons/confirmation/conf...
The Ash Authentication framework. Contribute to team-alembic/ash_authentication development by creating an account on GitHub.
Right here's my config:
I only have magic link at the moment, but will be adding Google-based OAuth hence the need for the confirmation strategy
I'll look at recreating this tomorrow, I feel like the auto_confirm_actions should handle this, but I haven't used the confirm addon myself yet. I'll report back with my findings, until then you can use the workaround with setting the date manually
Awesome, thanks!
I only had time for some surface level investigating, but from what I gathered so far, because you actually seed the user first the create action for sign in is doing an upsert which is detected and treated as an update. So it hits your confirmed change confirmation addon config which doesn't have the auto_confirm_actions and prevent_hijacking options set like your confirm_new_user config. I'm still curious about how this actually plays all together as it doesn't feel very intuitive. I will write more once I gather some more information