Auth blocking (#1261)

This commit is contained in:
matt korwel
2025-06-20 10:46:41 -07:00
committed by GitHub
parent 7c4af82da4
commit 7c8a1da8fe
3 changed files with 73 additions and 0 deletions

View File

@@ -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,
};
};