feat: Google OAuth, session expiry banner, useSession fix & auth tests#344
Merged
BigBen-7 merged 2 commits intoMay 29, 2026
Conversation
- 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
|
@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! 🚀 |
BigBen-7
approved these changes
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
closed #279,
closed #280,
closed #281,
closed #282
#279 – Google OAuth on login & sign-up pages
login-form.tsxthat redirects to/api/auth/google; errors surfaced as toasts.NEXT_PUBLIC_GOOGLE_AUTH_ENABLEDenv-var gate fromsignup-form.tsxso the Google button always renders on the sign-up page.#280 – Session expiry warning banner
SessionExpiredBannerto poll every 30 s and show an orange warning banner when the session is within 5 minutes of expiry./api/auth/refresh) and Log Out buttons./login?expired=1.#281 – useSession graceful expiry handling
checkSessionin atry/catchso storage errors never produce an unhandled rejection.toast.errornotification when the session expires.isTokenExpiredandgetTokenExpiryhelpers for reuse.#282 – Unit tests for useAuthState & useSession
src/__tests__/useAuthState-useSession.test.tscovering:isTokenExpired/getTokenExpirypure helpersuseSession: no-token redirect, expired-token redirect + toast, valid token (no redirect), 60 s poll, error handlinguseAuthState: loading state, authenticated state after timer, redirect when unauthenticatedAdditional bug fixes
authContext.tsx: added missingcreateContext/useStateimports; fixed token key from"token"→"auth_token"to matchauth.ts.events/page.tsx: removed duplicatevisibleCount/sentinelRefdeclarations that caused a compile error.verify/page.tsx: added missinguseEffectimport.auth-forms.test.tsx: addednext/navigationmock so LoginForm tests pass after the router was added.Testing
All 103 tests pass (
npm test). No new warnings introduced.