fix: show session expired modal instead of silent redirect to login#31
Merged
wicky-zipstack merged 1 commit intomainfrom Apr 8, 2026
Merged
fix: show session expired modal instead of silent redirect to login#31wicky-zipstack merged 1 commit intomainfrom
wicky-zipstack merged 1 commit intomainfrom
Conversation
- Trigger showSessionExpiredModal on 401 in axios interceptor - Show modal with "Session Expired" message before redirecting - Suppress error toasts when session expired modal is showing - User must click "Login" to proceed to login page
|
| Filename | Overview |
|---|---|
| frontend/src/auth/RequireAuth.js | Refactored to show a blocking "Session Expired" modal (closable={false}, maskClosable={false}) when !isLoggedIn && showSessionExpiredModal, instead of silently redirecting. handleLoginRedirect now resets the modal flag before navigating. The Outlet is no longer co-rendered with the modal, preventing protected content from appearing to an unauthenticated user. |
| frontend/src/service/axios-service.js | Added useSessionStore.getState().setShowSessionExpiredModal(true) in the 401 interceptor path, using the correct Zustand out-of-hook pattern for an effect callback context. |
| frontend/src/service/notification-service.js | Imports useSessionStore and uses getState() inside notify to suppress all error toasts while showSessionExpiredModal is true. This broadens the original 401-only suppression to cover all concurrent error notifications while the modal is visible. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[API Request] --> B{401 Response?}
B -- Yes --> C[axios-service: setShowSessionExpiredModal true]
C --> D[axios-service: clear sessionDetails]
D --> E{RequireAuth renders}
E -- isLoggedIn=false AND showSessionExpiredModal=true --> F[Show Session Expired Modal]
F --> G[User clicks Login]
G --> H[setShowSessionExpiredModal false]
H --> I[navigate to /login]
B -- No --> J[Normal response handling]
E -- isLoggedIn=false AND no modal flag --> I
E -- isLoggedIn=true --> K[Render Outlet]
F --> L[notification-service suppresses all error toasts]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: frontend/src/service/notification-service.js
Line: 54-60
Comment:
**Overly broad notification suppression**
The added `useSessionStore.getState().showSessionExpiredModal` condition now suppresses **all** error notifications while the modal is visible — not just those originating from 401 responses. If any in-flight request (e.g., a concurrent 500 or network error) fails after the session-expired modal appears, its error toast will be silently swallowed.
The original intent (per the PR description) was to avoid *duplicate* toasts for the 401 that triggered the modal, but this check goes further and mutes all error feedback.
If the goal is only to avoid the duplicate 401 toast, the original condition (`error?.response?.status === 401`) already covered that. The extra clause only matters for non-401 errors that arrive while the modal is open. Consider scoping the suppression to 401 only, or adding a comment acknowledging the broader suppression is intentional:
```suggestion
if (
error?.response?.status === 401 ||
// Suppress all error toasts while the session-expired modal is shown,
// since any concurrent request failures are likely a consequence of
// the expired session and would only add noise.
useSessionStore.getState().showSessionExpiredModal
) {
return;
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix: show session expired modal instead ..." | Re-trigger Greptile
Deepak-Gnanasekar
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Why
How
setShowSessionExpiredModal(true)on 401 response in the interceptorshowSessionExpiredModalis true to avoid duplicate notificationsCan this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
Screenshots
N/A
Checklist