Skip to content

fix(auth): correct localStorage boolean type mismatch causing auth bypass#19

Open
KGFCH2 wants to merge 1 commit into
omroy07:mainfrom
KGFCH2:fix/auth-localstorage-type-comparison-bug
Open

fix(auth): correct localStorage boolean type mismatch causing auth bypass#19
KGFCH2 wants to merge 1 commit into
omroy07:mainfrom
KGFCH2:fix/auth-localstorage-type-comparison-bug

Conversation

@KGFCH2
Copy link
Copy Markdown
Contributor

@KGFCH2 KGFCH2 commented Jun 2, 2026

Related Issue

Closes #18

Summary

Fixes a critical localStorage type mismatch bug where === true (boolean) was compared to the string "true" returned by localStorage.getItem(). Also replaces disruptive alert() calls with inline error messages and adds password validation.

Changes Made

  • Fix localStorage.getItem("isLoggedIn") === true=== "true"
  • Add return after redirect to prevent post-redirect form processing
  • Replace all alert() calls with inline role=alert + aria-live messages
  • Add minimum password length validation (6 characters) on registration
  • Add .trim() on email/name fields to reject whitespace-only inputs

Testing

  • Tested: Registered → logged out → visited login.html → auto-redirect fires correctly
  • Tested: Invalid credentials show inline error (no alert popup)
  • Tested: Whitespace-only email/password correctly rejected

Impact

Previously logged-in users were forced to re-authenticate on every visit. This fix ensures session continuity and significantly improves UX.

Checklist

  • Code follows project standards
  • Tested locally
  • No unrelated changes included
  • Accessibility considered (aria-live, role=alert)

…pass

Critical bug: localStorage.getItem() always returns strings, never native
booleans. The previous check === true always evaluated to false because
'true' (string) !== true (boolean), meaning the auto-redirect for already-
logged-in users on the login page never fired.

Changes:
- Fix type check: localStorage.getItem('isLoggedIn') === 'true'
- Add early return after redirect to prevent form processing post-redirect
- Replace all alert() calls with accessible inline error/success messages
  (uses role=alert and aria-live for screen reader compatibility)
- Add minimum password length validation (6 chars) on registration
- Add .trim() on string inputs to prevent whitespace-only submissions
- Improve UX: 1500ms delay before redirect on successful registration
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

@KGFCH2 is attempting to deploy a commit to the Om Roy's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 [Bug] Login auto-redirect never fires — localStorage boolean type mismatch

1 participant