Repository navigation
fix(settings): list devices without Better Auth's freshness gate - #597
Merged
Merged
Conversation
Settings › Account showed "Session is not fresh" to anyone who signed in more than a day ago, because Better Auth's list-sessions requires a fresh session (it returns each session's token). - Add /api/profile/sessions: GET lists the caller's active sessions with no tokens; DELETE ends one by id (never the current one, same-origin only). - Account section uses the new route; unlink and set-password keep the freshness gate and now show a translated "Sign in again" note instead of the raw error (set-password returns code SESSION_NOT_FRESH). - Session expiry reads "expires in 7 days" instead of "just now". - StatusNote warn tone uses --warn-* tokens so it follows dark mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 8103fba5-7b13-4b07-9193-067f979c1023) |
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.
Summary
list-sessionssits behindfreshSessionMiddleware(freshAge, 1 day) because it returns each session's token./api/profile/sessions:GETlists the caller's active sessions without tokens (id +currentflag);DELETE { id }ends one of the caller's own sessions by id. It refuses the current session and cross-site requests. With no secret in the response, the freshness gate isn't needed./signin?next=/employer/settings?show=sign-in) instead of the raw error./api/profile/sign-innow returnscode: "SESSION_NOT_FRESH"for that case.time.until, now "expires in 7 days");StatusNotewarntone used literal light colours and stayed bright in dark mode — now--warn-*tokens (also affects the existing warn notes in Models).Related
None.
Checklist
pnpm checkpasses (lint + typecheck) — eslint + tsc on the web app, 0 errorspnpm --filter @launchstack/web testpasses — ran profile, i18n and brand suites (218 passed), not the whole suiteTesting
apps/web/__tests__/api/profile/sessions.route.test.ts: listing works on a 10-day-old session, order (current first, then most recent), expired sessions dropped, notokenin the response, 401 signed out; DELETE by id works, refuses the current session, another user's session (404), cross-site (403) and a missing id (400).list-sessions→ 403SESSION_NOT_FRESH; the new route → 200, no tokens.next. A freshly signed-in session passes the gate.npx jest src/i18nconfirms en/zh-CN keys match.Notes for reviewers
userId, so another user's id reads exactly like an ended session (404).🤖 Generated with Claude Code
Note
Medium Risk
New session list/revoke API touches auth session lifecycle and CSRF checks; design avoids exposing tokens but server-side delete still must stay scoped to the caller's sessions only.
Overview
Fixes Settings › Account showing "Session is not fresh" for sign-ins older than a day by replacing Better Auth's token-bearing
list-sessionswith a new/api/profile/sessionsAPI.GETreturns active sessions as ids plus acurrentflag (no tokens), sorted with this browser first.DELETE { id }revokes another of the caller's sessions server-side, blocks ending the current session, cross-site requests, and foreign ids (404). Account now loads and ends sessions through this route instead of the auth client.Unlink and set password still require a fresh sign-in;
/api/profile/sign-inaddscode: "SESSION_NOT_FRESH", and the UI shows a translated warn note with Sign in again (sign out → sign-in with return to settings). Session rows usetime.untilfor expiry wording;StatusNotewarn styling moves to--warn-*tokens (en/zh strings and route tests included).Reviewed by Cursor Bugbot for commit 94baae3. Bugbot is set up for automated code reviews on this repo. Configure here.