Skip to content

fix: correct remember me token persistence#451

Merged
KaranUnique merged 1 commit into
Canopus-Labs:mainfrom
KRITIKA-l:fix-remember-me
Jul 14, 2026
Merged

fix: correct remember me token persistence#451
KaranUnique merged 1 commit into
Canopus-Labs:mainfrom
KRITIKA-l:fix-remember-me

Conversation

@KRITIKA-l

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the Remember Me login bug by ensuring token persistence is controlled in one place only. The login flow now stores the token in either localStorage or sessionStorage based on the checkbox state, instead of having updateUser() overwrite it afterward.

What Changed

  • Removed token persistence from updateUser() in the user context.
  • Updated login flow to explicitly manage token storage based on Remember Me.
  • Ensured the opposite storage location is cleared so stale tokens do not override the selected session type.

Files Updated

  • frontend/src/pages/Auth/Login.jsx
  • frontend/src/context/userContext.jsx

Bug Fixed #444

Before this change:

  • Remember Me unchecked still resulted in the token being saved to localStorage.
  • The session could survive browser restarts unexpectedly.

After this change:

  • Remember Me checked -> token stays in localStorage
  • Remember Me unchecked -> token stays in sessionStorage

Testing Notes

  • Log in with Remember Me unchecked and confirm the token only exists in sessionStorage.
  • Log in with Remember Me checked and confirm the token only exists in localStorage.
  • Refreshing or closing the browser should now match the selected option.

Impact

This restores expected authentication behavior and makes session persistence consistent for users.

@KaranUnique KaranUnique merged commit 552ec1c into Canopus-Labs:main Jul 14, 2026
2 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.

[Bug]: Remember Me is ignored because login token is always saved to localStorage

2 participants