Skip to content

feat: Google OAuth, session expiry banner, useSession fix & auth tests#344

Merged
BigBen-7 merged 2 commits into
Lead-Studios:mainfrom
authenticeasy-sys:feat/auth-google-oauth-session-expiry-tests
May 29, 2026
Merged

feat: Google OAuth, session expiry banner, useSession fix & auth tests#344
BigBen-7 merged 2 commits into
Lead-Studios:mainfrom
authenticeasy-sys:feat/auth-google-oauth-session-expiry-tests

Conversation

@authenticeasy-sys
Copy link
Copy Markdown
Contributor

@authenticeasy-sys authenticeasy-sys commented May 28, 2026

Summary

closed #279,
closed #280,
closed #281,
closed #282


#279 – Google OAuth on login & sign-up pages

  • Added Continue with Google button to login-form.tsx that redirects to /api/auth/google; errors surfaced as toasts.
  • Removed NEXT_PUBLIC_GOOGLE_AUTH_ENABLED env-var gate from signup-form.tsx so the Google button always renders on the sign-up page.

#280 – Session expiry warning banner

  • Rewrote SessionExpiredBanner to poll every 30 s and show an orange warning banner when the session is within 5 minutes of expiry.
  • Banner offers Extend Session (calls /api/auth/refresh) and Log Out buttons.
  • On expiry without extension the user is redirected to /login?expired=1.

#281 – useSession graceful expiry handling

  • Wrapped checkSession in a try/catch so storage errors never produce an unhandled rejection.
  • Added toast.error notification when the session expires.
  • Exported isTokenExpired and getTokenExpiry helpers for reuse.

#282 – Unit tests for useAuthState & useSession

  • New test file src/__tests__/useAuthState-useSession.test.ts covering:
    • isTokenExpired / getTokenExpiry pure helpers
    • useSession: no-token redirect, expired-token redirect + toast, valid token (no redirect), 60 s poll, error handling
    • useAuthState: loading state, authenticated state after timer, redirect when unauthenticated

Additional bug fixes

  • authContext.tsx: added missing createContext / useState imports; fixed token key from "token""auth_token" to match auth.ts.
  • events/page.tsx: removed duplicate visibleCount / sentinelRef declarations that caused a compile error.
  • verify/page.tsx: added missing useEffect import.
  • auth-forms.test.tsx: added next/navigation mock so LoginForm tests pass after the router was added.

Testing

All 103 tests pass (npm test). No new warnings introduced.

- Lead-Studios#279: Add Google OAuth button to login and sign-up pages; button
  redirects to /api/auth/google and surfaces errors as toasts.
  Remove NEXT_PUBLIC_GOOGLE_AUTH_ENABLED gate on sign-up form.

- Lead-Studios#280: Rewrite SessionExpiredBanner with 5-min warning, Extend Session
  and Log Out buttons; extending calls /api/auth/refresh endpoint;
  on expiry without extension user is redirected to /login?expired=1.

- Lead-Studios#281: Wrap useSession checkSession in try/catch; show toast.error on
  expiry; export isTokenExpired and getTokenExpiry helpers.

- Lead-Studios#282: Add unit tests for useAuthState and useSession covering valid
  session, expired session redirect, network error, and loading states.

Also fix pre-existing bugs:
- authContext.tsx: add missing createContext/useState imports; fix token
  key from 'token' to 'auth_token' to match auth.ts.
- events/page.tsx: remove duplicate visibleCount/sentinelRef declarations.
- verify/page.tsx: add missing useEffect import.
- auth-forms.test.tsx: add next/navigation mock for LoginForm tests.

Closes Lead-Studios#279, Lead-Studios#280, Lead-Studios#281, Lead-Studios#282
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@authenticeasy-sys Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@BigBen-7 BigBen-7 merged commit f40499d into Lead-Studios:main May 29, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants