"Remember me" checkbox on login #48

Closed
opened 2026-10-15 10:23:32 +00:00 by Syndria98 · 8 comments
Owner

Add a "remember me" checkbox on the login form so that it remembers the user session on this device

Add a "remember me" checkbox on the login form so that it remembers the user session on this device
Syndria98 added the ai-ready label 2026-10-15 10:23:32 +00:00
Agent added the working label 2026-10-15 11:03:09 +00:00
Collaborator

Now I have the full picture. Implementing:

Now I have the full picture. Implementing:
Collaborator

Now the i18n strings in all three locales:

Now the i18n strings in all three locales:
Collaborator

Now the test file, following the repo's node --test source-check convention — with the TokenStore itself tested functionally via stubbed browser storage:

Now the test file, following the repo's `node --test` source-check convention — with the `TokenStore` itself tested functionally via stubbed browser storage:
Collaborator

Pre-existing failure on the clean tree — unrelated to my change. Now let me run my new test file and the full suite:

Pre-existing failure on the clean tree — unrelated to my change. Now let me run my new test file and the full suite:
Collaborator

All 9 of my tests pass; the only suite failure is the pre-existing one from master. Let me quickly check why that file fails differently than mine — I want to make sure my new file doesn't share the cause:

All 9 of my tests pass; the only suite failure is the pre-existing one from master. Let me quickly check why that file fails differently than mine — I want to make sure my new file doesn't share the cause:
Collaborator

The failing file is a pre-existing problem unrelated to this issue — I'll note it in the summary and leave it untouched. Final review of my complete diff:

The failing file is a pre-existing problem unrelated to this issue — I'll note it in the summary and leave it untouched. Final review of my complete diff:
Collaborator

Done. Summary of the change for issue #48 ("Remember me" checkbox on login):

What was implemented

A login now has two lifetimes: with Remember me the session persists on the device (localStorage + 30-day token); without it the token lives only in sessionStorage, so closing the browser ends the session (token keeps the existing 48 h cap).

  • frontend/app/services/TokenStore.js (new) — single place that decides which browser store holds the login token: GetToken() (sessionStorage, falling back to localStorage), SetToken(token, remember) (clears both, writes one), ClearToken(). A separate leaf module so both Server.js and User.js use it without an import cycle.
  • frontend/app/services/User.js — SetUser(token, remember) stores via the token store; GetUser/LoadUser read through GetToken(); LogoutUser clears both stores.
  • frontend/app/services/Server.js — the axios auth interceptor reads the token through GetToken() instead of localStorage directly.
  • frontend/app/components/windows/LoginWindow.vue — "Remember me on this device" checkbox (default checked, matching the app's previous always-persistent behavior) between password and the login button; its value is sent to /user/login and passed to SetUser.
  • backend/src/routes/user.js — POST /user/login accepts remember; expiresIn: remember ? 2592000 : 172800 (30 days vs the existing 48 h).
  • frontend/app/components/views/ServiceLinkAuthorize.vue — its sign-in passes remember = true explicitly so the service-link flow keeps the persistent session it had before.
  • i18n — login.remember-me added to all three locales (en/es/ca).

Tests — new tests/remember-me.test.js (9 tests): TokenStore is exercised for real against stubbed browser storages (remember→localStorage, plain→sessionStorage, store switching replaces the token, clearing empties both), plus source checks for the checkbox wiring, token reads going through the store, the backend lifetime split, and the locale strings. All 9 pass. Full suite: 130/131 — the one failure is tests/item-folder-sync.test.js, which already fails identically on the clean tree (a top-level await makes Node 20 re-parse it as ESM and its requires then fail); it is unrelated to this issue and was left untouched.

Done. Summary of the change for issue #48 ("Remember me" checkbox on login): **What was implemented** A login now has two lifetimes: with *Remember me* the session persists on the device (localStorage + 30-day token); without it the token lives only in `sessionStorage`, so closing the browser ends the session (token keeps the existing 48 h cap). - **`frontend/app/services/TokenStore.js`** (new) — single place that decides which browser store holds the login token: `GetToken()` (sessionStorage, falling back to localStorage), `SetToken(token, remember)` (clears both, writes one), `ClearToken()`. A separate leaf module so both `Server.js` and `User.js` use it without an import cycle. - **`frontend/app/services/User.js`** — `SetUser(token, remember)` stores via the token store; `GetUser`/`LoadUser` read through `GetToken()`; `LogoutUser` clears both stores. - **`frontend/app/services/Server.js`** — the axios auth interceptor reads the token through `GetToken()` instead of `localStorage` directly. - **`frontend/app/components/windows/LoginWindow.vue`** — "Remember me on this device" checkbox (default checked, matching the app's previous always-persistent behavior) between password and the login button; its value is sent to `/user/login` and passed to `SetUser`. - **`backend/src/routes/user.js`** — `POST /user/login` accepts `remember`; `expiresIn: remember ? 2592000 : 172800` (30 days vs the existing 48 h). - **`frontend/app/components/views/ServiceLinkAuthorize.vue`** — its sign-in passes `remember = true` explicitly so the service-link flow keeps the persistent session it had before. - **i18n** — `login.remember-me` added to all three locales (en/es/ca). **Tests** — new `tests/remember-me.test.js` (9 tests): `TokenStore` is exercised for real against stubbed browser storages (remember→localStorage, plain→sessionStorage, store switching replaces the token, clearing empties both), plus source checks for the checkbox wiring, token reads going through the store, the backend lifetime split, and the locale strings. All 9 pass. Full suite: 130/131 — the one failure is `tests/item-folder-sync.test.js`, which already fails identically on the clean tree (a top-level `await` makes Node 20 re-parse it as ESM and its `require`s then fail); it is unrelated to this issue and was left untouched.
Collaborator

Implementation is ready for review: #52

Implementation is ready for review: https://git.aranroig.com/Syndria98/dragonroll/pulls/52
Agent added help wanted and removed working labels 2026-10-15 11:11:18 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Syndria98/dragonroll#48