summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/useAuthCommand.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/ui/hooks/useAuthCommand.ts')
-rw-r--r--packages/cli/src/ui/hooks/useAuthCommand.ts11
1 files changed, 11 insertions, 0 deletions
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,
};
};