Skip to content

feat: warn guests before their session expires - #3983

Merged
AlexAndBear merged 4 commits into
mainfrom
feat/guest-session-expiry-warning
Oct 23, 2026
Merged

AlexAndBear merged 4 commits into
mainfrom
feat/guest-session-expiry-warning

Conversation

@JammingBen

@JammingBen JammingBen commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Description

Guests currently lose their session without notice once it expires. This PR warns them 15 minutes before expiry and lets them refresh the session via a PIN sent by email, without leaving the page.

  • Expiry warning: a persistent notification shows the expiry time and offers "Request PIN". Once requested, it offers "Enter PIN", which opens a modal to refresh the session in place.
  • After expiry: a PIN requested before expiry can still be entered. Otherwise the guest can request a new invitation, which opens the renew page.
  • Errors: rate limiting shows when to retry, share errors (expired/removed share) show the matching message without a retry, transient errors offer a retry.
  • Session expiry: the verify token/PIN endpoints return the expiry, which is shifted to the client clock using the server's Date header (only available same-origin or if the server exposes the header).
  • Multiple tabs: renewals are coordinated via Web Locks and localStorage, so tabs reuse a pending PIN instead of invalidating it. A session refreshed or a PIN requested in another tab updates the warning.

The implementation will get a bit simpler once opencloud-eu/opencloud#3786 landed in the server. But for now, this does work.

Issue

closes #3797

How to test

On a valid guest session, run the following in the browser console to trick Web into thinking the session is about to expire:

const e = JSON.parse(localStorage.getItem('oc.guestSessionExpiry'))
e.expirationDateTime = new Date(Date.now() + 10 * 60 * 1000).toISOString()
localStorage.setItem('oc.guestSessionExpiry', JSON.stringify(e))
window.dispatchEvent(new StorageEvent('storage', { key: 'oc.guestSessionExpiry' }))

Then go through the renewal flow.

Warn 15 minutes before the guest session expires and let the guest
request a PIN from the notification to refresh the session. Entering
the PIN is only offered if it was requested before the session expired.

The expiry is shifted to the client clock via the server's Date header.
Sessions refreshed in another tab, e.g. via the emailed link, are
picked up via localStorage.
@JammingBen
JammingBen force-pushed the feat/guest-session-expiry-warning branch from 9ba27a1 to 9688c34 Compare October 22, 2026 10:35
@JammingBen
JammingBen marked this pull request as ready for review October 22, 2026 12:10
@AlexAndBear
AlexAndBear merged commit 61856fa into main Oct 23, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Guests] Notify guests before their session expires

3 participants