From 7c8a1da8fe0856e7ebedcd543f82e20f09816222 Mon Sep 17 00:00:00 2001 From: matt korwel Date: Fri, 20 Jun 2025 10:46:41 -0700 Subject: Auth blocking (#1261) --- packages/cli/src/ui/hooks/useAuthCommand.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'packages/cli/src/ui/hooks/useAuthCommand.ts') diff --git a/packages/cli/src/ui/hooks/useAuthCommand.ts b/packages/cli/src/ui/hooks/useAuthCommand.ts index 2c2b5f93..5cc67a07 100644 --- a/packages/cli/src/ui/hooks/useAuthCommand.ts +++ b/packages/cli/src/ui/hooks/useAuthCommand.ts @@ -31,6 +31,8 @@ export const useAuthCommand = ( setIsAuthDialogOpen(true); }, []); + const [isAuthenticating, setIsAuthenticating] = useState(false); + useEffect(() => { const authFlow = async () => { if (isAuthDialogOpen || !settings.merged.selectedAuthType) { @@ -38,6 +40,7 @@ export const useAuthCommand = ( } try { + setIsAuthenticating(true); await performAuthFlow( settings.merged.selectedAuthType as AuthType, config, @@ -51,6 +54,8 @@ Message: ${getErrorMessage(e)}` : `Failed to login. Message: ${getErrorMessage(e)}`; setAuthError(errorMessage); openAuthDialog(); + } finally { + setIsAuthenticating(false); } }; @@ -73,10 +78,16 @@ Message: ${getErrorMessage(e)}` // For now, we don't do anything on highlight. }, []); + const cancelAuthentication = useCallback(() => { + setIsAuthenticating(false); + }, []); + return { isAuthDialogOpen, openAuthDialog, handleAuthSelect, handleAuthHighlight, + isAuthenticating, + cancelAuthentication, }; }; -- cgit v1.2.3