Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Log out and go to the login page when the session expires

Aperta
#66 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@ayushnandi718-dev ci sta già lavorando.

Dal 21/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug difficulty: medium frontend hacktoberfest help wanted
Context

Login tokens expire after a while. When that happens, the API answers with 401, and client/src/utils/api.js removes the token from localStorage, but that's all. The app still thinks the user is logged in. They stay on the page, every action silently fails, and they only end up on the login page after reloading.

Files likely involved
  • client/src/utils/api.js (the response interceptor)
  • client/src/context/AuthContext.jsx (logout)
Acceptance criteria
  • When any request returns 401 while the user is logged in, the app logs them out (the same as clicking Logout), goes to /login, and shows the toast "Your session has expired. Please log in again."
  • A wrong password on the login page must not trigger this. POST /auth/login also returns 401 for wrong credentials, so that case keeps showing "Invalid email or password." as today.
  • Several requests failing at the same moment cause one logout and one toast, not several.
  • Avoid importing React code into api.js. One clean way is for api.js to accept a callback (for example setUnauthorizedHandler(fn)) that AuthContext registers.
How to test
  1. Log in, then in DevTools → Application → Local Storage, change the token value to something invalid.
  2. Click around (open Tasks, create a task): you're sent to the login page once, with the "session expired" toast.
  3. On the login page, enter a wrong password: the normal error shows, with no redirect and no "session expired" toast.

New here? 👋 Comment below to ask to work on this issue, and wait to be assigned. Then follow CONTRIBUTING.md for setup and how to open a pull request. Questions are welcome in the comments or in Discussions.

Lingua principale
JavaScript
Stelle
3
Fork
2
Merge medio
6h 50m
PR unite (30g)
37

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di KEX-03/taskflow

Tutte le issue di KEX-03/taskflow

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.