Skip to content
SprecherEast
Issue 587

enhancement: "Keep me signed in for a week" on the sign-in form

Back to our plan
Done
enhancementauthpriority: medium

Problem

Residents get signed out after about two hours, so they have to log in over and over. A person on their own phone or computer should be able to tick "Keep me signed in" and stay signed in for a week, then be asked to log in again. Not ticking it keeps today's behavior (two hours).

Summary of the owner's request (2026-11-02, Claude chat, text): a user should be able to choose to stay signed in by ticking a Keep me signed in box, and then stay signed in for about one week, after which they are signed out automatically and asked to sign in again. He is repeatedly signed out on his own computer.

Proposed fix

A "Keep me signed in for a week" checkbox on the sign-in form, unticked by default (a shared computer stays safe unless someone chooses otherwise).

Technical details:

  • The checkbox is part of the sign-in action's input (signInSchema, strict like every action schema).
  • Native first: Payload's auth.tokenExpiration is one value per collection, and in 3.91 it sets the token's expiry, the stored session's expiresAt and the cookie's expiry together. login takes no per-sign-in override. Setting it to a week would make every sign-in last a week with no opt-in, including on shared computers, so it doesn't fit.
  • Official plugins: none for this. Third-party auth libraries: not needed (#266 chose Payload's own auth).
  • Own code, small, in the accounts module (data/session.ts): after Payload's login succeeds and the box is ticked, sign the same claims again for a week with Payload's exported jwtSign, extend that session's expiresAt (Payload's removeExpiredSessions deletes sessions past it the next time the account signs in anywhere, which would end the remembered session early), and set the cookie with Payload's generatePayloadCookie for a week. Without the box, nothing changes.
  • The length lives in one constant, and the label's "a week" is built from it.
  • Sign-out, password change and the lockout keep working unchanged: the remembered session has the same sid, so logoutOperation revokes it.
  • /admin sign-in is Payload's own form and stays at two hours (out of scope).

Acceptance criteria

  • Not done: The sign-in form has an unticked "Keep me signed in for a week" checkbox, labelled and accessible, usable on a phone.
  • Not done: Ticked: the auth cookie and the token last 7 days, and the session stays valid on the server for 7 days.
  • Not done: Unticked: exactly today's behavior (cookie and token last two hours).
  • Not done: After 7 days the person is signed out and asked to log in again.
  • Not done: Signing out ends a remembered session; another sign-in on the same account doesn't end it early.
  • Not done: A wrong password still counts towards the lockout, and every refusal is still the same generic failure.
  • Not done: Tests cover the schema, the action, the session lifetimes and the form; docs/project.md and docs/guidelines/security.md say how long a sign-in lasts and why.

Area

auth

Priority

priority: medium


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab