Skip to content

fix(auth): improve cross-browser login resilience and sync with backend updates - #84

Open
Shubham15986 wants to merge 1 commit into
RECursion-NITD:mainfrom
Shubham15986:fix/cross-browser-login-and-profile-sync
Open

fix(auth): improve cross-browser login resilience and sync with backend updates#84
Shubham15986 wants to merge 1 commit into
RECursion-NITD:mainfrom
Shubham15986:fix/cross-browser-login-and-profile-sync

Conversation

@Shubham15986

Copy link
Copy Markdown
Contributor

Description

This PR resolves cross-browser login responsiveness issues (particularly on Firefox and Safari) and aligns frontend authentication and profile handling with recent backend security updates (commit 282e3f8: Patched IDOR in Google Login and commit 8eb4b70: JWT permission restrictions).


Context & Root Cause Analysis

  1. Backend User Creation & Lookup Sync:
    • Recent backend security updates changed user lookups to query by email rather than assuming username = email.split('@')[0].
    • The frontend previously threw User not found in local storage when localStorage.getItem("user") was missing or desynced, leaving the login form stuck in a submitting (disabled) state.
  2. Safari & Firefox Popup Handling:
    • Popups initiated from generic <div> elements were blocked by Safari and Firefox's Enhanced Tracking Protection / popup policies without triggering error callbacks.
  3. Missing Profile Navigation (HTTP 404):
    • New Google logins without an existing profile or role returned 404/401, previously resulting in abrupt logouts instead of smoothly routing users to complete their profile details at /profile/edit.
  4. Google Font MIME Error:
    • Fixed a typo in public/index.html (Mullish instead of Mulish) that triggered a stylesheet MIME type mismatch error.

Key Changes

  • Token & Profile Decoding Fallback (src/api/userInfo.js & src/context/AuthContext.js):
    • Added safe fallback parsing from JWT authTokens if the user object in localStorage is missing or incomplete.
    • Ensured status is reliably reset to "typing" across all authentication success and error paths.
  • Safari & Firefox Google Login Compatibility (src/components/GoogleLogin/Glogin.jsx):
    • Converted the trigger to a semantic <button type="button"> to ensure browser user-activation trust.
    • Added comprehensive onError handler and toast alerts for popup blocking and network failures.
  • Smooth Profile Completion Flow (src/components/Login.jsx & src/components/Layout.jsx):
    • On 404 profile lookup (new or incomplete accounts), users are gracefully redirected to /profile/edit to complete required fields rather than being logged out.
  • Font Fix (public/index.html):
    • Removed broken Mullish Google Font link.

Testing & Verification

  • Verified Google OAuth login and standard credential login in Chrome, Firefox, and Safari.
  • Verified automatic cleanup on invalid/expired tokens (401).
  • Verified smooth redirect to /profile/edit on new user registration/login (404 profile).
  • Confirmed zero local proxy artifacts are present in the PR branch.

- Add fallback JWT username decoding in userInfo.js to prevent 'User not found in local storage' errors
- Update Google login button in Glogin.jsx to use semantic button with error handling and toasts for Safari/Firefox popup compatibility
- Gracefully handle 404 profile lookups in Login.jsx and Layout.jsx by redirecting to /profile/edit for completion
- Ensure status is reset to typing across all auth flows in AuthContext.js
- Remove broken Google font link in public/index.html causing MIME type mismatch
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

@Shubham15986 is attempting to deploy a commit to the RECursion'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.

1 participant