AshAuthentication confirmation page not using correct layout
The page served for
/auth/user/confirm_new_user?confirm=longtokenhere does not appear to be using my application's layout template, because it does not have any of the elements in <head> that the rest of my app has.
My router looks like this:
Solution:Jump to solution
If I explicitly pass
path: "/auth/user/", then the root layout is used. I'm now thinking the URL I send in the email is incorrect.12 Replies
thats correct, it uses its own layout
OK, then how is it meant to get the CSRF token? The root layout has this:
Without that, submitting the form raises a
Plug.CSRFProtection.InvalidCSRFTokenErroryour router appears to be missing the
put_secure_browser_headers plug - that might be what does it:put_app_browser_headers is my own wrapper that calls that plug.
ah hah
Is there something missing?
not sure. there definitely shouldn't be any CSRF error
is this on phoenix 1.18? Maybe their new layout changes cause problems and we have to accept some kind of "layout component" option?
No, still 1.17.
SignInLive and ResetLive appear to be using my app's "root" layout, but ConfirmLive is not for whatever reason, which seems wrong.
I think I might see the problem. The generated route is
Which is not under /auth, which is what is passed via opts[:auth_routes_prefix]. I think the first argument to scope in the confirm_route macro may be incorrect.
https://github.com/team-alembic/ash_authentication_phoenix/blob/5f05b73b2d2b36f77ed53377d0e91989c523d319/lib/ash_authentication_phoenix/router.ex#L536
path is "/#{strategy}", which would be "/confirm_new_user".Solution
If I explicitly pass
path: "/auth/user/", then the root layout is used. I'm now thinking the URL I send in the email is incorrect.Right, so everything under
/auth is more like API endpoints for AshAuthentication, and the LiveView routes should be outside that, going by the routes in a base AAP setup.
I'm submitting a PR to correct the Confirmation Tutorial. But why is anything under /auth serving a human-readable HTML page when I visit it in the browser?GitHub
docs: correct route in sample confirmation email by aidalgol · Pul...
In the Confirmation Tutorial, the example mailer used the wrong route. AshAuthenticationPhoenix LiveView pages are served outside the auth routes prefix.