fix(auth): drop auth-signal writes from UserMenu logout closure #79
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
psa-systems/mokosh-apps!79
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/logout-no-signal-writes-pre-navigation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PR #78 switched the UserMenu logout to navigate at the bunyip-api
OptionalUser-backedGET /v1/auth/logout?url=...endpoint, which correctly clears the .a8n.systems-scoped session cookies. The user reports the symptom did not actually change: clicking Logout still lands them back on the mokosh dashboard, still authenticated.The bug is the closure ordering, not the URL.
hooks::auth::use_logoutcarries an explicit warning, copied here for the record: "the call tolocation.replaceMUST run before any write to the auth signal. Otherwiseauth.write(user = None)schedules a Dioxus re-render; on that re-render the route guard sees an unauthenticated user on/dashboardand callsnavigator.push(Route::Login {}), which puts/loginon TOP of/dashboardin history; the subsequentlocation.replaceraces the router push and the user ends up navigated away from the hub logout URL and back onto the dashboard view." The UserMenu closure introduced in PR #78 ignored that warning: it wroteauth.write().user = None(andset_access_token(None), which is the same signal-write pattern) and then calledlocation.replace. The race plays out exactly as the warning describes; nothing about the URL change altered the outcome.This change drops both signal writes. The closure now does the minimum: close the dropdown menu, clear sessionStorage (so a refresh after the navigation cannot rehydrate), then
location.replace(hub_logout). The full page reload that follows resets every in-memory signal anyway, so the explicit writes were always redundant on top of being racy.No other changes. The hub_logout URL, the Profile -> /settings link, and the local memberships synthesis from PR #78 all stay as they were.