Skip to content

Notify user about Session expiries - #365

Merged
Bohreromir merged 10 commits into
mainfrom
worktree-fix-356-session-expiry
Oct 23, 2026
Merged

Bohreromir merged 10 commits into
mainfrom
worktree-fix-356-session-expiry

Conversation

@Bohreromir

Copy link
Copy Markdown
Member

Now the user gets a blocking modal informing him about the session expiry.
This makes the cockpit not fail randomly from a user perspective.

API routes redirected unauthenticated requests to the HTML login page,
so client-side fetch callers failed with a JSON parse error once the
session had expired. Page routes still redirect to the login page.

Refs #356

asdf
@Bohreromir Bohreromir self-assigned this Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 64.79% 8702 / 13430
🔵 Statements 63.89% 11705 / 18318
🔵 Functions 66.19% 2789 / 4213
🔵 Branches 55.02% 5001 / 9088
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/hooks.client.ts 0% 0% 0% 0% 10-26
src/hooks.server.ts 0% 0% 0% 0% 17-138
src/lib/client/session.svelte.ts 100% 100% 100% 100%
src/lib/components/Modal.svelte 86.76% 71.92% 93.75% 86.27% 55, 73-74, 80-81, 115, 127-130
src/lib/components/layout/SessionExpiredModal.svelte 0% 100% 0% 0% 11-53
src/lib/server/auth-guard.ts 100% 100% 100% 100%
src/routes/(app)/+layout.svelte 0% 0% 0% 0% 10-100
Generated in workflow #1133 for commit 2c00fa7 by the Vitest Coverage Report Action

Wrap window.fetch in the client init hook so that any same-origin 401
triggers a session check. A 401 alone is not proof of an expired session
(the storage API uses it for a missing connection), so only an explicit
"no session" answer from better-auth marks the session as expired.

Refs #356

fix(auth): ignore session check results after the layout unmounts

Refs #356
Show a non-dismissible modal with a link to sign in again, returning the
user to the current page afterwards. The session is also checked when
the tab becomes visible again, so the modal appears before the next
API call. Modal gains a dismissible prop and passes through attributes
such as aria-labelledby.

Refs #356
Closes #356

test(e2e): check the session modal survives a repeated Escape

Refs #356
@Bohreromir
Bohreromir force-pushed the worktree-fix-356-session-expiry branch from e0ed631 to 13cfaa7 Compare October 8, 2026 09:04
@Bohreromir
Bohreromir marked this pull request as ready for review October 8, 2026 09:19
@Bohreromir Bohreromir linked an issue Oct 8, 2026 that may be closed by this pull request

@lfrancke lfrancke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One thing you can dismiss and the other is a comment I'm unsure about...

Comment thread src/lib/components/layout/SessionExpiredModal.svelte
Comment thread src/lib/client/session.svelte.ts Outdated
@lfrancke lfrancke moved this from Development: Waiting for Review to Development: In Review in Stackable Engineering Oct 20, 2026
Sessions are database-backed, so a check with disableRefresh no longer
extends the session and polling does not keep an idle tab signed in.
Check every 60 s while the tab is visible, in addition to when the user
returns to it, and drop the outdated comments about stateless mode.

Refs #356
@Bohreromir
Bohreromir requested a review from lfrancke October 22, 2026 08:28
@Bohreromir
Bohreromir added this pull request to the merge queue Oct 23, 2026
@Bohreromir Bohreromir moved this from Development: In Review to Development: Done in Stackable Engineering Oct 23, 2026
Merged via the queue into main with commit 117cdb7 Oct 23, 2026
12 checks passed
@Bohreromir
Bohreromir deleted the worktree-fix-356-session-expiry branch October 23, 2026 11:15
@lfrancke lfrancke moved this from Development: Done to Done in Stackable Engineering Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

Error when signed out due to timelimit

2 participants