Skip to content

Add coach Google Sign-In with backend id_token exchange#84

Open
sahilkashyap64 wants to merge 3 commits into
mainfrom
codex/integrate-google-sign-in-for-coach-login
Open

Add coach Google Sign-In with backend id_token exchange#84
sahilkashyap64 wants to merge 3 commits into
mainfrom
codex/integrate-google-sign-in-for-coach-login

Conversation

@sahilkashyap64
Copy link
Copy Markdown
Collaborator

Motivation

  • Add Google Sign-In to the coach login flow and exchange the Google id_token with the backend so coaches can authenticate via Google.
  • Persist backend-issued access_token/refresh_token and session data (user_id, user_type, profile, locations) for subsequent API calls.
  • Surface common backend Google auth error cases as clear user messages while keeping email/password as a fallback.

Description

  • Added coachGoogleLogin(idToken) to src/api/auth.js to POST /api/auth/google/coach-login and return { ok, status, data }.
  • Extended auth context in src/hooks/useAuth.jsx with loginWithGoogle which exchanges the id_token, validates coach-only access, stores tokens via storeTokens, and persists normalized session in local storage.
  • Implemented Google Identity Services integration in src/components/auth/LoginPage.jsx to dynamically load the SDK, render the official Google button, obtain the SDK credential (id_token), and call loginWithGoogle; email/password login remains as fallback.
  • Mapped backend error cases to user-facing messages for google_email_not_verified, account_exists_with_different_role, invalid_google_token, and missing backend client-id configuration, and added README notes about VITE_GOOGLE_AUTH_CLIENT_ID / VITE_GOOGLE_CLIENT_ID alignment with backend.

Testing

  • Ran the unit/integration test suite with npm test, all tests passed (10 tests, 0 failures).
  • Built the production bundle with npm run build, which completed successfully.

Codex Task

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 9, 2026

Deploy Preview for thunderous-muffin-603a62 ready!

Name Link
🔨 Latest commit 8a79f82
🔍 Latest deploy log https://app.netlify.com/projects/thunderous-muffin-603a62/deploys/69b017394a96380008666536
😎 Deploy Preview https://deploy-preview-84--thunderous-muffin-603a62.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 9, 2026

PR Preview Action v1.6.2

🚀 View preview at
https://CodeMyMobile.github.io/TTP_Coach_Web_Public/pr-preview/pr-84/

Built to branch gh-pages at 2026-03-10 13:06 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant