Skip to content

fix(auth): show logout's own notification, not login's - #936

Merged
thostetler merged 3 commits into
adsabs:masterfrom
thostetler:fix/logout-notification
Sep 29, 2026
Merged

thostetler merged 3 commits into
adsabs:masterfrom
thostetler:fix/logout-notification

Conversation

@thostetler

@thostetler thostetler commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Logging out reloaded the page with the login redirect's
?notify=account-login-success still in the URL, so it showed "You have
been logged in." after a logout. account-logout-success existed but
nothing ever emitted it.

  • Added reloadWithNotification() to overwrite the notify param and reload
    via window.location.replace(), so Back can't land on the stale URL
  • Logout success emits account-logout-success, failure emits
    account-logout-failed (previously replayed the login toast)
  • Fixed account-logout-failed, which was declared with
    id: 'account-logout-success'
  • Added src/lib/useSession.test.tsx covering all three paths

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Bundle size

Shared by all pages: 629.6 kB (+0.2 kB) ⚪

No route changed by more than 1 kB. ✅

First load = polyfills + shared _app chunks + route chunks, gzipped.

@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.1%. Comparing base (0cf34dc) to head (f00e31e).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/components/Notification/Notification.tsx 71.5% 1 Missing and 1 partial ⚠️
src/components/NavBar/AccountDropdown.tsx 0.0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #936     +/-   ##
========================================
- Coverage    57.4%   55.1%   -2.3%     
========================================
  Files         338     374     +36     
  Lines       10646   11462    +816     
  Branches     2338    2514    +176     
========================================
+ Hits         6107    6305    +198     
- Misses       3917    4526    +609     
- Partials      622     631      +9     
Files with missing lines Coverage Δ
src/components/Notification/stripNotifyParam.ts 100.0% <100.0%> (ø)
src/lib/useSession.ts 100.0% <100.0%> (+53.4%) ⬆️
src/store/slices/notification.ts 57.2% <ø> (ø)
src/components/NavBar/AccountDropdown.tsx 8.7% <0.0%> (-4.3%) ⬇️
src/components/Notification/Notification.tsx 80.0% <71.5%> (ø)

... and 48 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thostetler
thostetler marked this pull request as ready for review September 17, 2026 18:38
Copilot AI lite review requested due to automatic review settings September 17, 2026 18:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved test incompatibility and logout navigation/notification issues block approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Updates logout navigation to display dedicated logout notifications instead of replaying the login notification.

Changes:

  • Rewrites successful logout targets to account-logout-success.
  • Corrects the account-logout-failed notification ID.
  • Adds logout behavior tests.
File summaries
File Review summary
src/store/slices/notification.ts Corrects the failed-logout notification identifier.
src/lib/useSession.ts Adds logout notification navigation. Moderate findings: assign preserves stale history (2 votes); protected routes can hide the logout confirmation (1 vote); failed logout can replay the login notification (2 votes).
src/lib/useSession.test.tsx Adds logout tests. Critical finding (2 votes): redefining window.location is incompatible with jsdom 26 and causes the suite to fail before running.
Review details

Suppressed comments (1)

src/lib/useSession.ts:31

  • High impact (confidence: high): When logout is triggered from /user/settings, /user/libraries, or /user/notifications, this target is still a protected route. The middleware redirects the unauthenticated reload to the login page and replaces notify with login-required (src/middleware.ts:286-308), so the new logout confirmation is not shown for those common logout locations. Navigate to a public destination after logout or preserve the logout notification through that redirect.
        window.location.assign(`${url.pathname}${url.search}${url.hash}`);
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +31 to +34
Object.defineProperty(window, 'location', {
configurable: true,
value: { ...window.location, href, assign: vi.fn() },
});
Comment thread src/lib/useSession.ts Outdated
// redirect, which replays on reload.
const url = new URL(window.location.href);
url.searchParams.set('notify', 'account-logout-success' satisfies NotificationId);
window.location.assign(`${url.pathname}${url.search}${url.hash}`);
Comment thread src/lib/useSession.ts Outdated
// redirect, which replays on reload.
const url = new URL(window.location.href);
url.searchParams.set('notify', 'account-logout-success' satisfies NotificationId);
window.location.assign(`${url.pathname}${url.search}${url.hash}`);
@thostetler thostetler changed the title fix(auth): show the logout notification instead of replaying the login one fix(auth): show logout's own notification, not login's Sep 23, 2026
@thostetler
thostetler force-pushed the fix/logout-notification branch from c775b29 to f66ad1d Compare September 23, 2026 13:13
@shinyichen

Copy link
Copy Markdown
Member

@thostetler Not sure if this would be an issue. After logging out (now has param notify=account-logout-success), and login again, the param is still there.

…n one

Logging out reloaded the current URL, which still carried
notify=account-login-success from the login redirect, so the toast read
"You have been logged in." Nothing ever emitted account-logout-success,
so logout had no confirmation of its own.

- Rewrites notify to account-logout-success on the logout reload target
- Corrects the account-logout-failed entry, which declared itself with
  id account-logout-success
A failed logout reloaded the current URL, which still carried the login redirect's notify param, so the user saw the login toast and account-logout-failed was never emitted.

Both logout outcomes now reload through one helper that overwrites notify with the matching id, using replace() rather than assign() so Back cannot return to the stale URL.
@thostetler
thostetler force-pushed the fix/logout-notification branch from f66ad1d to e9d438b Compare September 29, 2026 20:00
notify is consumed during hydration, but nothing removed it, so the toast replayed on reload, on Back, and through any link built from the current path. Logging out and back in showed the logout toast, because the login next param carried the logout notify along.

The param is now stripped from the URL after hydration, from the next param the account dropdown builds, and from the target login redirects to.
@thostetler
thostetler force-pushed the fix/logout-notification branch from e9d438b to f00e31e Compare September 29, 2026 20:03
@thostetler
thostetler merged commit ef57c7e into adsabs:master Sep 29, 2026
5 of 6 checks passed
@thostetler
thostetler deleted the fix/logout-notification branch September 29, 2026 20:10
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.

3 participants