Skip to content

fix useTriggerProviderReconnect#15620

Merged
charlesBochet merged 2 commits intomainfrom
fix-oauth2-reconnect
Nov 4, 2025
Merged

fix useTriggerProviderReconnect#15620
charlesBochet merged 2 commits intomainfrom
fix-oauth2-reconnect

Conversation

@neo773
Copy link
Copy Markdown
Member

@neo773 neo773 commented Nov 4, 2025

No description provided.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR fixes the useTriggerProviderReconnect hook by ensuring OAuth reconnection flows always redirect back to /settings/accounts after completion.

Key Changes:

  • Modified the hook to always set redirectLocation to /settings/accounts via getSettingsPath(SettingsPath.Accounts) when calling triggerApisOAuth
  • Updated all test expectations to validate that redirectLocation is consistently set, even when custom options are provided
  • The change ensures a predictable user experience where reconnecting an account always returns users to the accounts settings page

Behavior:

  • For OAuth providers (Google, Microsoft): Now always overrides any custom redirectLocation in options with /settings/accounts
  • For IMAP_SMTP_CALDAV: Behavior unchanged - still navigates using the useNavigateSettings hook
  • The spread operator ...options is placed before redirectLocation, ensuring the override always takes precedence

Confidence Score: 5/5

  • This PR is safe to merge with no significant risks
  • The changes are minimal, well-tested, and follow a clear intent to standardize redirect behavior. All tests have been updated to match the new behavior, demonstrating thorough coverage. The implementation correctly uses getSettingsPath utility and properly merges options while ensuring redirectLocation is always overridden.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-front/src/modules/settings/accounts/hooks/useTriggerProviderReconnect.ts 4/5 Added automatic redirectLocation override to ensure OAuth reconnections always redirect to /settings/accounts page. The change forces a consistent redirect location regardless of provided options.
packages/twenty-front/src/modules/settings/accounts/hooks/tests/useTriggerProviderReconnect.test.tsx 5/5 Updated test expectations to validate that redirectLocation is always set to /settings/accounts, even when custom options are provided. Tests comprehensively cover the new override behavior.

Sequence Diagram

sequenceDiagram
    participant User
    participant Component
    participant Hook as useTriggerProviderReconnect
    participant OAuthHook as useTriggerApisOAuth
    participant Navigate
    participant Backend

    User->>Component: Clicks reconnect button
    Component->>Hook: triggerProviderReconnect(provider, accountId, options)
    
    alt IMAP provider
        alt no accountId provided
            Hook->>Navigate: Navigate to new connection
        else accountId provided
            Hook->>Navigate: Navigate to edit connection
        end
    else OAuth provider
        Note over Hook: Merge options with fixed redirectLocation
        Hook->>OAuthHook: triggerApisOAuth(provider, mergedOptions)
        OAuthHook->>Backend: Initiate provider flow
        Backend-->>User: Redirect after completion
    end
Loading

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 4, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:34849

This environment will automatically shut down when the PR is closed or after 5 hours.

@charlesBochet charlesBochet merged commit 5d5999b into main Nov 4, 2025
58 checks passed
@charlesBochet charlesBochet deleted the fix-oauth2-reconnect branch November 4, 2025 23:51
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 4, 2025

Thanks @neo773 for your contribution!
This marks your 53rd PR on the repo. You're top 1% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

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.

2 participants