Multiple confirmation strategies with interaction

It appears to be impossible to use require_interaction? true with more than one confirmation strategy, because using the confirm_route macro more than once produces a compile-time error.
confirm_route MyApp.Accounts.User, :confirm_new_user, auth_routes_prefix: "/auth"
confirm_route MyApp.Accounts.User, :confirm_email_change, auth_routes_prefix: "/auth"
confirm_route MyApp.Accounts.User, :confirm_new_user, auth_routes_prefix: "/auth"
confirm_route MyApp.Accounts.User, :confirm_email_change, auth_routes_prefix: "/auth"
== Compilation error in file lib/my_app_web/router.ex ==
** (RuntimeError) attempting to redefine live_session :auth_confirm.
live_session routes must be declared in a single named block.
== Compilation error in file lib/my_app_web/router.ex ==
** (RuntimeError) attempting to redefine live_session :auth_confirm.
live_session routes must be declared in a single named block.
Am I missing something, or is this a bug?
Solution:
but yes, the two routes need to be disambiguated, via the as option
Jump to solution
5 Replies
sevenseacat
sevenseacat•3mo ago
confirm_route is for the confirmation addon, not specifically the require_interaction? option
Solution
sevenseacat
sevenseacat•3mo ago
but yes, the two routes need to be disambiguated, via the as option
aidalgol
aidalgolOP•3mo ago
Are you sure? Without any calls to confirm_route in my router, mix phx.routes shows,
POST /auth/user/confirm_email_change AshAuthentication.AddOn.Confirmation
GET /auth/user/confirm_email_change AshAuthentication.AddOn.Confirmation
POST /auth/user/confirm_new_user AshAuthentication.AddOn.Confirmation
GET /auth/user/confirm_new_user AshAuthentication.AddOn.Confirmation
POST /auth/user/confirm_email_change AshAuthentication.AddOn.Confirmation
GET /auth/user/confirm_email_change AshAuthentication.AddOn.Confirmation
POST /auth/user/confirm_new_user AshAuthentication.AddOn.Confirmation
GET /auth/user/confirm_new_user AshAuthentication.AddOn.Confirmation
sevenseacat
sevenseacat•3mo ago
I deleted the message about the URLs because I realized it was wrong 😅 but using as to disambiguate them is correct
aidalgol
aidalgolOP•3mo ago
oh, oops... sorry. 🤦 OK, yeah, that does it. Thanks!

Did you find this page helpful?