fix and update
This commit is contained in:
@@ -12,6 +12,9 @@ import {
|
||||
approveOAuthAuthorization,
|
||||
checkOAuthConsent,
|
||||
fetchOAuthClientPublicInfo,
|
||||
getApiErrorMessage,
|
||||
isGatewayUnavailableError,
|
||||
resetGatewayCircuit,
|
||||
type OAuthConsentCheckResponse
|
||||
} from '@/lib/api';
|
||||
import { deliverOAuthPopupResult, parsePopupOAuthParams, postOneTapResult } from '@/lib/oauth-popup-bridge';
|
||||
@@ -47,6 +50,10 @@ function OAuthAuthorizeContent() {
|
||||
|
||||
const returnUrl = useMemo(() => `/auth/oauth/authorize?${oauthQuery.toString()}`, [oauthQuery]);
|
||||
|
||||
useEffect(() => {
|
||||
resetGatewayCircuit();
|
||||
}, []);
|
||||
|
||||
const clientLabel = clientName ?? consentInfo?.client?.name ?? 'Приложение';
|
||||
|
||||
const approve = useCallback(async () => {
|
||||
@@ -63,7 +70,13 @@ function OAuthAuthorizeContent() {
|
||||
}
|
||||
window.location.href = data.redirectUrl;
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Ошибка OAuth авторизации');
|
||||
const message = getApiErrorMessage(err, 'Ошибка OAuth авторизации');
|
||||
setError(
|
||||
message ??
|
||||
(isGatewayUnavailableError(err)
|
||||
? 'Сервер API временно недоступен. Подождите несколько секунд и нажмите «Разрешить» снова.'
|
||||
: 'Ошибка OAuth авторизации')
|
||||
);
|
||||
autoApproveStartedRef.current = false;
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
@@ -113,7 +126,13 @@ function OAuthAuthorizeContent() {
|
||||
}
|
||||
} catch (err) {
|
||||
if (!cancelled) {
|
||||
setError(err instanceof Error ? err.message : 'Не удалось проверить согласие');
|
||||
const message = getApiErrorMessage(err, 'Не удалось проверить согласие');
|
||||
setError(
|
||||
message ??
|
||||
(isGatewayUnavailableError(err)
|
||||
? 'Сервер API временно недоступен. Подождите несколько секунд — форма обновится автоматически.'
|
||||
: 'Не удалось проверить согласие')
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (!cancelled) setCheckingConsent(false);
|
||||
|
||||
Reference in New Issue
Block a user