Merged
Conversation
Contributor
Greptile SummaryThis PR adds self-service session management to the Account page, allowing users to view all their active sessions, see which one is current, and revoke individual sessions — including with a warning when revoking the current session. On the backend, two new endpoints (
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User (Browser)
participant UI as AccountPage
participant BE as /admin/v1/me/sessions
participant SS as SessionStore
U->>UI: Open Account page
UI->>BE: GET /me/sessions
BE->>SS: list_user_sessions(external_id)
SS-->>BE: [session_a, session_b, ...]
BE-->>UI: { data, enhanced_enabled, current_session_id }
UI-->>U: Render session cards (current highlighted)
U->>UI: Click Revoke on session_b
UI-->>U: Confirm dialog ("Revoke session?")
U->>UI: Confirm
UI->>BE: DELETE /me/sessions/{session_b_id}
BE->>SS: get_session(session_b_id)
SS-->>BE: session (external_id matches ✓)
BE->>SS: delete_session(session_b_id)
SS-->>BE: ok
BE-->>UI: { sessions_revoked: 1 }
UI->>UI: Remove session_b_id from revokingSessionIds
UI->>BE: GET /me/sessions (cache invalidated)
BE-->>UI: Updated session list
Note over U,UI: If session_b was the CURRENT session:<br/>BE returns 401 on refetch,<br/>UI shows error — but auth state<br/>is NOT cleared (bug)
Prompt To Fix All With AIThis is a comment left during a code review.
Path: ui/src/pages/AccountPage.tsx
Line: 86-93
Comment:
**Revoking the current session doesn't trigger client-side logout**
When a user confirms revoking their own active session, the `onSuccess` handler removes it from `revokingSessionIds` and invalidates the sessions query — but never calls `logout()`. The subsequent refetch of `/admin/v1/me/sessions` returns a 401 (the session cookie is now invalid), setting `sessionsError` to `true` and showing "Failed to load sessions. Please try again." The user's auth context remains intact, so they appear logged-in while their server session is gone, leaving them in a broken state.
`handleRevokeSession` already computes `isCurrent` before mutating, but that knowledge isn't carried into `onSuccess`. The fix is to compare `variables.path.session_id` against `sessions?.current_session_id` inside `onSuccess`, and call `logout()` (already imported via `useAuth`) when they match — skipping the query invalidation in that branch since the user is about to be logged out anyway.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "Review fixes" |
Owner
Author
Owner
Author
Owner
Author
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.
No description provided.