Skip to content

fix: use raw paths for reset/register route definitions in sign_in_route#729

Merged
jimsynz merged 2 commits intomainfrom
fix/scoped-reset-register-routes
Apr 14, 2026
Merged

fix: use raw paths for reset/register route definitions in sign_in_route#729
jimsynz merged 2 commits intomainfrom
fix/scoped-reset-register-routes

Conversation

@jimsynz
Copy link
Copy Markdown
Collaborator

@jimsynz jimsynz commented Apr 14, 2026

Summary

  • Fixes double-nesting of reset_path and register_path routes when sign_in_route is used inside a Phoenix router scope
  • The sign-in route was unaffected because it used the raw path option in the live/4 call, but reset_path/register_path were passed through Phoenix.Router.scoped_path/2 (adds scope prefix) and then used in live/4 (adds scope prefix again)
  • Adds separate *_route_path variables holding the raw paths for live/4 route definitions, while keeping the scoped paths in session data for link generation

Test plan

  • Added assertions to the existing sign_in_routes respects the inherited router scope test verifying that /nested/reset and /nested/register routes exist at the correct paths
  • Full test suite passes (131 tests, 0 failures)

Fixes team-alembic/ash_authentication#1151

jimsynz added 2 commits April 14, 2026 15:32
…oute`

When `sign_in_route` is used inside a Phoenix router `scope`, the
reset and register routes were double-nested. For example, inside
`scope "/admin"`, a `reset_path: "/reset"` would generate a route at
`/admin/admin/reset` instead of `/admin/reset`.

The sign-in route itself was unaffected because it used the raw path
option (`unquote(path)`) in the `live/4` call, letting the Phoenix
scope mechanism add the prefix once. However, `reset_path` and
`register_path` were passed through `Phoenix.Router.scoped_path/2`
(which adds the scope prefix) and then used directly in `live/4`
(which adds the scope prefix again).

The fix maintains separate variables: the scoped paths are still used
in session data (so the LiveView generates correct links), while the
raw paths are used for route definitions.

Fixes team-alembic/ash_authentication#1151
@jimsynz jimsynz merged commit fec2d9a into main Apr 14, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When using the sign_in_route macro, generated reset/remember links are incorrect

1 participant