Skip to content

fix: site title reverts to 'DM Alerts' after Discord OAuth redirect#111

Merged
hokiepokedad2 merged 2 commits into
mainfrom
feature/106-site-title
Apr 4, 2026
Merged

fix: site title reverts to 'DM Alerts' after Discord OAuth redirect#111
hokiepokedad2 merged 2 commits into
mainfrom
feature/106-site-title

Conversation

@hokiepokedad2
Copy link
Copy Markdown
Contributor

Summary

  • Load site settings after the OAuth callback stores the JWT token

Root cause

App.ngOnInit() calls settingsService.loadOnce() during bootstrap, but on the OAuth callback page, this fires before CallbackComponent extracts the JWT from the URL fragment and stores it in localStorage. The GET /api/settings request goes out without a Bearer token, gets a 401, and the error is silently swallowed. Since loaded stays false but nobody calls loadOnce() again, settings (including custom_title) are never loaded for the session.

Fix

Call settingsService.loadOnce() in handleTokenFromCallback() after the token is stored and user is loaded. The retry succeeds because the token is now in localStorage for the auth interceptor.

Closes #106

Test plan

  • Set a custom site title in admin settings
  • Log out and log back in via Discord OAuth
  • After redirect, the custom title should appear immediately (not "DM Alerts")
  • Subsequent page navigations should retain the custom title
  • Direct page loads (already logged in) should still show the custom title

App.ngOnInit() calls settingsService.loadOnce() before the OAuth
callback stores the JWT token, so GET /api/settings returns 401
and settings (including custom_title) are never loaded. The title
stays as the default "DM Alerts" for the entire session.

Fix: call loadOnce() in handleTokenFromCallback() after the token
is stored and the user is loaded. Since the initial loadOnce() failed
(loaded flag stayed false), this retry succeeds with the valid token.

Closes #106
@hokiepokedad2
Copy link
Copy Markdown
Contributor Author

Code Review: PR #111

Verdict: APPROVED

Summary

Fixes the site title reverting to "DM Alerts" after Discord OAuth redirect by calling settingsService.loadOnce() in handleTokenFromCallback() after the JWT is stored.

Root Cause

Race condition: App.ngOnInit() fires loadOnce() before CallbackComponent stores the JWT → GET /api/settings returns 401 (silently swallowed) → loaded stays false → nobody retries → settings never load.

Category Assessment
Correctness Fix is correct. loadOnce() retries successfully since loaded is still false. The signal-based siteTitle reacts automatically.
Side effects None — loadOnce() is idempotent. Short-circuits if already loaded.
Circular dependency AuthServiceSettingsService — safe, no reverse dependency.
Subscription leak Fire-and-forget .subscribe() on a one-time HTTP call. No leak risk.
Tests Updated to expect GET /api/settings after auth. 461 frontend + 560 backend tests pass.

Note

loadOnce().subscribe() is fire-and-forget — navigation to /dashboard doesn't wait for it. The title might flash "DM Alerts" very briefly. If noticeable, await firstValueFrom(this.settingsService.loadOnce()) before navigating would fix it. Not a blocker for now.

No issues found.

@hokiepokedad2 hokiepokedad2 merged commit 51bc46b into main Apr 4, 2026
2 checks passed
@hokiepokedad2 hokiepokedad2 deleted the feature/106-site-title branch April 4, 2026 05:32
github-actions Bot added a commit that referenced this pull request Apr 4, 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.

bug: site title reverts to default 'DM Alerts' after Discord OAuth redirect

1 participant