T14.2 (D27): the offline sign-in window follows the server
/api/auth/me returns session_expires_at (the session token exp, UTC). The browser keeps it and never extends it: the fixed 12 hours and the sliding reset are gone. Offline before that time the app opens as normal. Offline after it the app opens in read-and-queue mode: no redirect, one mode line, changes are queued and held until a page load gets a good answer from the server. wpCacheAuth refreshes the cached user without moving the end time. D26 and D27 recorded as Accepted. tests/session_expiry_check.py (22 checks) fails against the old 12 hour rule.
This commit is contained in:
@@ -834,12 +834,22 @@ if okta_fake.is_active():
|
||||
|
||||
|
||||
@app.get("/api/auth/me")
|
||||
def whoami(user: models.User = Depends(auth.get_current_user)):
|
||||
def whoami(request: Request, user: models.User = Depends(auth.get_current_user)):
|
||||
"""Who is logged in. The frontend guard calls this on every page load.
|
||||
|
||||
`role` is normalized here so no page has to know that a pre-roles account stores
|
||||
'user' where it now means 'project_user'."""
|
||||
return {"user": {**user.to_dict(), "role": auth.normalize_role(user.role)}}
|
||||
'user' where it now means 'project_user'.
|
||||
|
||||
D27: `session_expires_at` is the `exp` claim of the session token, as a UTC time.
|
||||
The browser keeps it so the offline sign-in window ends when the server session
|
||||
ends. No column holds it: get_current_user has already validated this token, so
|
||||
the claim is read back from the same cookie."""
|
||||
claims = auth.is_request_authenticated(request) or {}
|
||||
exp = claims.get("exp")
|
||||
expires_at = (datetime.fromtimestamp(exp, tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
if isinstance(exp, (int, float)) else None)
|
||||
return {"user": {**user.to_dict(), "role": auth.normalize_role(user.role)},
|
||||
"session_expires_at": expires_at}
|
||||
|
||||
|
||||
# ── Display preferences (self-service) ─────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user