fix(routing): register #/auth route so Auth0 callback resolves correctly (#502)#503
Conversation
`auth.service.ts` configures Auth0's `callbackUrl` as
`${window.location.origin}/#/auth`, and `lfx-header.service.ts` forwards
the same value to the LFX header. After interactive login Auth0 redirects
the browser back to `#/auth`, but `app-routing.module.ts` only registered
the empty path `''` for AuthDashboardComponent — so the callback fell
through to the `**` wildcard and rendered PageNotFoundComponent, leaving
the user stranded with no in-app path back to the Contributor Console
even though they were fully authenticated.
This was masked on first login (the LFX header's own Auth0 SPA SDK
typically establishes the session via silent auth, so the contributor
console never had to do an interactive Auth0 redirect and the user
landed straight on /cla/project/...). It surfaced after an explicit
header-menu Logout: the next visit forced an interactive login, the
post-login redirect landed on /auth, and the missing route bit.
Add an explicit auth route mapped to AuthDashboardComponent so its
ngOnInit runs, reads PROJECT_ID/USER_ID/REDIRECT from localStorage and
router.navigate's the user back to
/cla/project/:projectId/user/:userId?redirect=...
Also strengthen the AuthDashboardComponent unit test: provide Router /
StorageService spies (the existing scaffolding "should create" test was
silently failing because ngOnInit was being executed against unmocked
services) and add a regression test asserting the storage-driven
navigation behaviour that the new route now exercises.
Tracks frontend issue: #502
Resolves: linuxfoundation/easycla#5032
Assisted by [Cursor](https://cursor.com/)
Signed-off-by: ahmedomosanya <aopeyemi@contractor.linuxfoundation.org>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughA new 'auth' route is added to the app routing module mapping to AuthDashboardComponent. The component spec is expanded with Router and StorageService mocks and a test verifying the component navigates to ChangesRouting and Navigation Test
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes an Auth0 callback routing bug in the Angular hash-based router by registering the missing #/auth route so the Auth0 post-login redirect lands on AuthDashboardComponent (instead of the wildcard 404), allowing the storage-driven redirect back into the CLA flow to execute.
Changes:
- Registers
path: 'auth'toAuthDashboardComponentinAppRoutingModuleto correctly resolve#/auth. - Strengthens
AuthDashboardComponentunit tests by stubbingRouter.navigateandStorageService.getItem, and adds a regression assertion for the expected navigation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/app/app-routing.module.ts |
Adds an explicit auth route mapping to AuthDashboardComponent so #/auth no longer falls through to the wildcard route. |
src/app/modules/dashboard/container/auth-dashboard/auth-dashboard.component.spec.ts |
Updates the test setup with Router/Storage spies and adds a regression test validating init-time navigation based on stored values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
authroute inapp-routing.module.tsmapped toAuthDashboardComponentso the Auth0 post-login redirect to${origin}/#/authresolves correctly instead of falling through to the**wildcard and renderingPageNotFoundComponent.AuthDashboardComponentunit test withRouter/StorageServicespies and adds a regression test asserting thestorage-driven navigation that the new route now runs.
Closes #502.
Tracked in linuxfoundation/easycla#5032 (mirror issue for commit-msg hook).
Why
auth.service.tsconfigures Auth0'scallbackUrlas${window.location.origin}/#/auth, but onlypath: ''was registered forAuthDashboardComponent. WithuseHash: true,#/authmatched neither''nor any other route → wildcard →PageNotFoundComponent, soAuthDashboardComponent.ngOnInit(which readsPROJECT_ID/USER_ID/REDIRECTfromlocalStorageand routes the user back into the CLA flow)never ran after the Auth0 callback. See
#502 for the full root-cause
write-up. Adding the route is the fix the issue recommends; it requires no
Auth0 tenant config changes.
Test plan
eslint './src/**/*.ts' --quiet).AuthDashboardComponentsuite passes; existing skeletonshould createtest fixed as a side effect of the new mocks. Suitewent from
10 FAILED, 23 SUCCESSonmain→9 FAILED, 24 SUCCESS;remaining 9 failures are pre-existing
should createstubs inunrelated services, unchanged by this PR.
ng serve+ Playwright:#/auth, matches the issue's screenshot.#/authwithprojectId/userId/redirectinlocalStorageredirects to#/cla/project/<projectId>/user/<userId>?redirect=...and renders the"What type of contributor are you?" screen.
#/(still resolves throughAuthDashboardComponent).(sign-link → login → header-menu Logout → re-paste sign-link →
re-login) against
easycla.dev.communitybridge.org.