Add client id to frontegg app#1688
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Pull request overview
This PR updates the Frontegg initialization to support client ID configuration and implements a singleton pattern to prevent multiple initializations. The changes convert the initialization function from accepting a simple string URL to an options object that can include URL, client ID, and tenant parameters.
- Refactored
initializeFronteggto accept an options object instead of separate parameters - Added singleton pattern to cache the Frontegg app instance
- Updated all call sites to use the new options object syntax
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/react-ui/src/app/lib/frontegg-setup.ts | Modified initialization function to accept options object, added singleton pattern, and introduced getFronteggApp helper |
| packages/react-ui/src/app/routes/cloud-connection/cloud-connection-page.tsx | Updated function call to pass URL as an options object |
| packages/react-ui/src/app/routes/cloud-connection/cloud-logout-page.tsx | Updated function call to pass URL as an options object |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Greptile OverviewGreptile SummaryThis PR adds Key Changes:
Code Quality:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant CloudConnectionPage
participant CloudLogoutPage
participant fronteggSetup
participant FronteggApp
participant Frontegg API
Note over User,Frontegg API: Authentication Flow
User->>CloudConnectionPage: Navigate to /cloud-connection
CloudConnectionPage->>CloudConnectionPage: Load flags (FRONTEGG_URL)
CloudConnectionPage->>fronteggSetup: initializeFrontegg({ url, clientId? })
alt First initialization
fronteggSetup->>FronteggApp: initialize(options with clientId)
fronteggSetup->>fronteggSetup: Store singleton instance
fronteggSetup-->>CloudConnectionPage: Return new FronteggApp
else Already initialized
fronteggSetup-->>CloudConnectionPage: Return cached FronteggApp
end
CloudConnectionPage->>FronteggApp: app.ready()
FronteggApp->>FronteggApp: Subscribe to store
alt Not authenticated
FronteggApp->>CloudConnectionPage: auth.isAuthenticated = false
CloudConnectionPage->>FronteggApp: loginWithRedirect()
FronteggApp->>Frontegg API: Redirect to login (with clientId)
Frontegg API-->>User: OAuth flow
User-->>Frontegg API: Complete authentication
Frontegg API-->>FronteggApp: Return tokens
else Already authenticated
FronteggApp->>CloudConnectionPage: auth.isAuthenticated = true
CloudConnectionPage->>CloudConnectionPage: Set cookies, store metadata
end
Note over User,Frontegg API: Logout Flow
User->>CloudLogoutPage: Navigate to /cloud-logout
CloudLogoutPage->>CloudLogoutPage: Load flags (FRONTEGG_URL)
CloudLogoutPage->>fronteggSetup: initializeFrontegg({ url })
fronteggSetup-->>CloudLogoutPage: Return cached FronteggApp
CloudLogoutPage->>CloudLogoutPage: Remove cookies
CloudLogoutPage->>FronteggApp: app.logout()
FronteggApp->>Frontegg API: Logout request
CloudLogoutPage->>CloudLogoutPage: Close window
|



Fixes OPS-3151