mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 04:30:48 +00:00
Auth blocking (#1261)
This commit is contained in:
parent
7c4af82da4
commit
7c8a1da8fe
3 changed files with 73 additions and 0 deletions
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue