Skip to content

Fix customize supertokens auth#1234

Merged
victor-enogwe merged 42 commits intomainfrom
fix-customize-supertokens-auth-refresh
Nov 15, 2025
Merged

Fix customize supertokens auth#1234
victor-enogwe merged 42 commits intomainfrom
fix-customize-supertokens-auth-refresh

Conversation

@victor-enogwe
Copy link
Contributor

What does this PR do?

This PR re-implements the Supertoken's Auth

Use Case

closes #1227
clean up for #1228

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates from supertokens-auth-react to supertokens-web-js, reimplementing authentication with a custom session management system and refactoring the Google OAuth flow.

Key Changes:

  • Migrated to supertokens-web-js v0.16.0, removing the React-specific auth library
  • Implemented custom Session class with RxJS-based event handling for session state management
  • Refactored authentication flow to use SuperTokens ThirdParty recipe with direct Google OAuth integration
  • Extracted user metadata management into a dedicated service and added skipOnboarding support

Reviewed Changes

Copilot reviewed 71 out of 72 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
yarn.lock Upgraded supertokens-web-js to v0.16.0, removed supertokens-auth-react and related unused dependencies
packages/web/src/common/classes/Session.ts New Session wrapper class providing event-based session management with RxJS observables
packages/web/src/auth/SessionProvider.tsx New SessionProvider for managing authentication state across the app
packages/web/src/common/hooks/useGoogleAuth.ts Centralized Google OAuth logic for reuse across onboarding and login flows
packages/web/src/views/Onboarding/OnboardingFlow.tsx Updated onboarding to support skipOnboarding metadata and improved flow control
packages/backend/src/common/middleware/supertokens.middleware.ts Configured ThirdParty recipe with Google OAuth and implemented signup/signin logic
packages/backend/src/user/services/user-metadata.service.ts Extracted user metadata operations into dedicated service
packages/backend/src/auth/services/compass.auth.service.ts Implemented separate googleSignup and googleSignin methods with user ID mapping
packages/backend/src/priority/services/priority.service.ts Refactored to use bulk upsert operations and support MongoDB sessions
packages/web/src/socket/SocketProvider.tsx Updated WebSocket handling to work with new session management

Copilot AI review requested due to automatic review settings November 14, 2025 15:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 75 out of 76 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (1)

packages/backend/src/auth/services/google.auth.service.ts:141

  • [nitpick] Method renamed from getAccessToken to refreshAccessToken, but the error message still says 'Google auth access token not returned'. Consider updating to 'Failed to refresh Google auth access token'.
  async refreshAccessToken() {
    const { token } = await this.oauthClient.getAccessToken();

    if (!StringV4Schema.safeParse(token).success) {
      throw error(
        AuthError.NoGAuthAccessToken,
        "Google auth access token not returned",
      );
    }

@victor-enogwe victor-enogwe force-pushed the fix-customize-supertokens-auth-refresh branch from e38c9bc to 3f3b21f Compare November 14, 2025 16:03
Copilot AI review requested due to automatic review settings November 14, 2025 18:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 69 out of 70 changed files in this pull request and generated 8 comments.

Copilot AI review requested due to automatic review settings November 14, 2025 19:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 69 out of 70 changed files in this pull request and generated 11 comments.

Comments suppressed due to low confidence (1)

packages/backend/src/auth/services/google.auth.service.ts:142

  • The method name changed from getAccessToken to refreshAccessToken, but the implementation only calls getAccessToken(). This is misleading. If the intent is to refresh the token, the implementation should be updated, or the method should be renamed back.
  async refreshAccessToken() {
    const { token } = await this.oauthClient.getAccessToken();

    if (!StringV4Schema.safeParse(token).success) {
      throw error(
        AuthError.NoGAuthAccessToken,
        "Google auth access token not returned",
      );
    }

@victor-enogwe victor-enogwe force-pushed the fix-customize-supertokens-auth-refresh branch from 17c774b to 7ef2e0d Compare November 14, 2025 19:59
Copilot AI review requested due to automatic review settings November 14, 2025 20:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 69 out of 70 changed files in this pull request and generated 10 comments.

- Add Session class to manage session-related functionalities using SuperTokens.
- Create useSession hook to handle session state and authentication checks.
- Introduce useGoogleAuth hook for Google login flow and integration with signup completion.
- Update GoogleButton component to make onClick optional.
- Refactor MobileSignIn and SignInWithGoogle components to utilize new hooks.
- Remove deprecated LoginView component and its associated tests.
- Adjust Tooltip styles for improved theme compatibility.
- Clean up socket connection handling in SocketProvider.
- Remove unused imports and code related to previous authentication methods.
- Update tests to reflect changes in authentication flow and session management.
- Updated user driver to use TokenPayload from google-auth-library.
- Renamed signInWithSuperTokens to googleSignup and loginWithSuperTokens to googleSignin in CompassAuthService.
- Refactored GoogleAuthService to refresh access token and handle errors more effectively.
- Changed error status for NoGAuthAccessToken to UNAUTHORIZED.
- Removed unused sync routes and methods related to stopping watches.
- Implemented UserController for fetching and updating user metadata.
- Created UserRoutes for user metadata endpoints.
- Removed USER_SIGN_OUT and USER_REFRESH_TOKEN constants from websocket.
- Updated WebSocketServer to handle user metadata instead of refresh tokens.
- Added skipOnboarding flag to UserMetadata and implemented logic to manage onboarding status.
- Refactored onboarding flow to skip welcome screens based on signup completion.
- Created UserApi for fetching and updating user metadata.
- Updated ProtectedRoute to handle session expiration more gracefully.
- Enhanced session management in SessionProvider.
- Cleaned up unused imports and optimized code structure across various components.
victor-enogwe and others added 19 commits November 14, 2025 21:23
…nProvider

fix: enhance socket connection error logging in SocketProvider
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
stopwatches if no active session on signout
…existence and simplify session initialization
…ity into priority service

test: add comprehensive tests for priority service methods

refactor: streamline priority creation logic with bulk upsert in priority service

fix: update websocket server to use user metadata service instead of user service

test: update sync controller tests to utilize user metadata service

refactor: enhance sync service with incremental Google Calendar sync logic

refactor: migrate user service methods to user metadata service for better separation of concerns

chore: remove unused user service methods related to Google refresh token

test: add tests for user metadata service to ensure correct functionality

feat: implement user ID to supertoken ID mapping seeder for user migration
@victor-enogwe victor-enogwe force-pushed the fix-customize-supertokens-auth-refresh branch from adb7b78 to 990a0df Compare November 15, 2025 06:54
@victor-enogwe victor-enogwe changed the title Fix customize supertokens auth refresh Fix customize supertokens auth Nov 15, 2025
Copilot AI review requested due to automatic review settings November 15, 2025 07:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 72 out of 73 changed files in this pull request and generated 4 comments.

@victor-enogwe victor-enogwe merged commit f8cf6e1 into main Nov 15, 2025
5 checks passed
@victor-enogwe victor-enogwe deleted the fix-customize-supertokens-auth-refresh branch November 15, 2025 07:50
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.

Rebuild Supertokens Authentication Flow Using Inbuilt FDI Endpoints

2 participants