-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(auth, settings): allow to impersonate on mono workspace mode #9451
Conversation
Added support for multi-workspace checks during impersonation and streamlined token verification flows. Adjusted session clearing and navigation logic to improve user transition between workspaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Enhanced impersonation functionality to support both single and multi-workspace environments, with improved session management and authentication flows.
- Added
clearSession
call before redirecting in single-workspace impersonation inuseImpersonate.ts
- Simplified
VerifyEffect
component by removinggetTokens()
wrapper and flattening verification logic - Moved
setIsVerifyPendingState
management intohandleVerify
inuseAuth.ts
for better state control - Added
isMultiWorkspaceEnabled
checks in impersonation flow to handle workspace-specific redirections - Streamlined token verification by removing unnecessary data returns from auth handler functions
3 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
if (isDefined(loginToken)) { | ||
setIsAppWaitingForFreshObjectMetadata(true); | ||
verify(loginToken); | ||
} else if (!isLogged) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: verify() returns a Promise but is not being awaited - this could cause race conditions if the verification fails
packages/twenty-front/src/modules/settings/admin-panel/hooks/useImpersonate.ts
Outdated
Show resolved
Hide resolved
@@ -268,6 +268,8 @@ export const useAuth = () => { | |||
|
|||
const handleVerify = useCallback( | |||
async (loginToken: string) => { | |||
setIsVerifyPendingState(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: setIsVerifyPendingState(true) should be wrapped in try/catch to ensure it gets set back to false if verification fails
…nation flow Simplified test assertions in `useAuth.test.tsx` by removing redundant property checks from the signup method. Enhanced `useImpersonate` hook by refactoring workspace condition logic and introducing fresh metadata states to improve session handling.
@ehconitin feel free to close it when you cherry-picked the commits |
Thanks @AMoreaux |
Added support for multi-workspace checks during impersonation and streamlined token verification flows. Adjusted session clearing and navigation logic to improve user transition between workspaces.