Skip to content

fix(routing): register #/auth route so Auth0 callback resolves correctly (#502)#503

Merged
ahmedomosanya merged 1 commit into
mainfrom
fix/issue-502-auth-callback-route
May 7, 2026
Merged

fix(routing): register #/auth route so Auth0 callback resolves correctly (#502)#503
ahmedomosanya merged 1 commit into
mainfrom
fix/issue-502-auth-callback-route

Conversation

@ahmedomosanya
Copy link
Copy Markdown
Collaborator

Summary

  • Adds the missing auth route in app-routing.module.ts mapped to
    AuthDashboardComponent so the Auth0 post-login redirect to
    ${origin}/#/auth resolves correctly instead of falling through to the
    ** wildcard and rendering PageNotFoundComponent.
  • Strengthens the AuthDashboardComponent unit test with Router /
    StorageService spies and adds a regression test asserting the
    storage-driven navigation that the new route now runs.

Closes #502.
Tracked in linuxfoundation/easycla#5032 (mirror issue for commit-msg hook).

Why

auth.service.ts configures Auth0's callbackUrl as
${window.location.origin}/#/auth, but only path: '' was registered for
AuthDashboardComponent. With useHash: true, #/auth matched neither
'' nor any other route → wildcard → PageNotFoundComponent, so
AuthDashboardComponent.ngOnInit (which reads PROJECT_ID / USER_ID /
REDIRECT from localStorage and 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

  • Lint clean (eslint './src/**/*.ts' --quiet).
  • Unit tests: AuthDashboardComponent suite passes; existing skeleton
    should create test fixed as a side effect of the new mocks. Suite
    went from 10 FAILED, 23 SUCCESS on main9 FAILED, 24 SUCCESS;
    remaining 9 failures are pre-existing should create stubs in
    unrelated services, unchanged by this PR.
  • Local ng serve + Playwright:
    • Pre-fix repro (route removed via hot-reload) → "Page Not Found" at
      #/auth, matches the issue's screenshot.
    • Post-fix → #/auth with projectId / userId / redirect in
      localStorage redirects to
      #/cla/project/<projectId>/user/<userId>?redirect=... and renders the
      "What type of contributor are you?" screen.
    • No regression on #/ (still resolves through AuthDashboardComponent).
  • Post-merge DEV check: re-run the original Page Not Found after Auth0 callback — no route registered for #/auth #502 repro end-to-end
    (sign-link → login → header-menu Logout → re-paste sign-link →
    re-login) against easycla.dev.communitybridge.org.

`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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 088b5003-8a04-4f87-a256-13b0a81dd6d6

📥 Commits

Reviewing files that changed from the base of the PR and between 8ecc59b and a993935.

📒 Files selected for processing (2)
  • src/app/app-routing.module.ts
  • src/app/modules/dashboard/container/auth-dashboard/auth-dashboard.component.spec.ts

Walkthrough

A 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 /cla/project/:projectId/user/:userId with a redirect query parameter on initialization.

Changes

Routing and Navigation Test

Layer / File(s) Summary
Routing Configuration
src/app/app-routing.module.ts
New route entry added for path 'auth' mapping to AuthDashboardComponent with full path matching.
Test Infrastructure & Navigation Verification
src/app/modules/dashboard/container/auth-dashboard/auth-dashboard.component.spec.ts
Router and StorageService mocks added to TestBed configuration; existing component creation test preserved; new test verifies component retrieves projectId, userId, and redirect URL from StorageService on init and calls Router.navigate with the constructed path and query parameters.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding the missing #/auth route for Auth0 callback resolution, which is the primary objective of this PR.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the root cause, solution, test plan, and expected outcomes.
Linked Issues check ✅ Passed The PR successfully addresses all coding objectives from issue #502: adding the 'auth' route to app-routing.module.ts and strengthening AuthDashboardComponent unit tests with Router/StorageService mocks and regression test.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the objectives: route registration in app-routing.module.ts and AuthDashboardComponent test improvements; no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-502-auth-callback-route

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' to AuthDashboardComponent in AppRoutingModule to correctly resolve #/auth.
  • Strengthens AuthDashboardComponent unit tests by stubbing Router.navigate and StorageService.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.

@ahmedomosanya ahmedomosanya merged commit 1181df0 into main May 7, 2026
17 checks passed
@ahmedomosanya ahmedomosanya deleted the fix/issue-502-auth-callback-route branch May 7, 2026 10:03
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.

Page Not Found after Auth0 callback — no route registered for #/auth

3 participants