Skip to content

fix(ui): handle auth/session errors using HTTP semantics#339

Open
VarshiniGunti wants to merge 3 commits into
PSMRI:mainfrom
VarshiniGunti:issue-114-api-status-ui-handling
Open

fix(ui): handle auth/session errors using HTTP semantics#339
VarshiniGunti wants to merge 3 commits into
PSMRI:mainfrom
VarshiniGunti:issue-114-api-status-ui-handling

Conversation

@VarshiniGunti
Copy link
Copy Markdown

📋 Description

JIRA ID: N/A (GitHub issue #114)

This PR updates MMU-UI to correctly consume REST-style HTTP error responses (4xx/5xx) instead of relying on side-effect navigation or opaque error objects.

What changed

  1. Auth guard behavior corrected
  • Updated AuthGuard.canActivate() to return explicit router-compatible values:
    • true for valid session response
    • UrlTree('/login') for invalid/expired session
  • Replaced side-effect-based router.navigate() flow with map(...) return logic.
  • Added catchError(...) fallback to route to login via UrlTree on HTTP errors.
  1. Login error handling aligned with HTTP semantics
  • Updated login error callback to process HttpErrorResponse.
  • Added status-based error message mapping for:
    • 400, 401, 403, 404, 409, 500
  • Preserved API-provided errorMessage when available.
  • Ensures users get consistent, meaningful feedback for real HTTP failures.

Motivation

Issue #114 requires UI to handle real HTTP status codes once backend endpoints stop returning 200 for all outcomes.
This PR makes authentication/session and login flows robust against 4xx/5xx semantics and removes route activation race behavior.


✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • New feature (non-breaking change which adds functionality)
  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

Validation performed

  • Verified canActivate now returns boolean | UrlTree and no longer depends on router.navigate() side effects.
  • Verified login flow handles HttpErrorResponse and displays status-aware messages.
  • Confirmed session-invalid/error paths redirect to /login consistently through guard return values.
  • Kept changes intentionally scoped to auth/session and login flow to reduce regression risk.

Linked scope

  • This PR is the MMU-UI half of issue #114 and pairs with the MMU-API PR that introduces proper backend HTTP status responses.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Warning

Rate limit exceeded

@VarshiniGunti has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 1 second before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: db8e47ba-16e0-42a0-93b7-1df359411372

📥 Commits

Reviewing files that changed from the base of the PR and between 22509ad and 28c6284.

📒 Files selected for processing (2)
  • src/app/app-modules/core/services/auth-guard.service.ts
  • src/app/app-modules/login/login.component.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 5, 2026

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.

1 participant