From cfcf3cf7594d8df48e024895619c05f4e3704d3d Mon Sep 17 00:00:00 2001 From: Mayursinh Sarvaiya Date: Wed, 11 Dec 2024 13:52:42 -0400 Subject: [PATCH] fix(auth): token renew failure (#3122) Signed-off-by: Mayursinh Sarvaiya Signed-off-by: Diego Caspi --- ui/src/features/auth/token-renew.tsx | 34 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/ui/src/features/auth/token-renew.tsx b/ui/src/features/auth/token-renew.tsx index 31fe7ae8f..571d069ca 100644 --- a/ui/src/features/auth/token-renew.tsx +++ b/ui/src/features/auth/token-renew.tsx @@ -79,25 +79,35 @@ export const TokenRenew = () => { } (async () => { - const response = await refreshTokenGrantRequest(as, client, oidcClientAuth, refreshToken, { - [allowInsecureRequests]: shouldAllowHttpRequest(), - additionalParameters: [['client_id', client.client_id]] - }); - - const result = await processRefreshTokenResponse(as, client, response); + try { + const response = await refreshTokenGrantRequest(as, client, oidcClientAuth, refreshToken, { + [allowInsecureRequests]: shouldAllowHttpRequest(), + additionalParameters: [['client_id', client.client_id]] + }); - if (!result.id_token) { + const result = await processRefreshTokenResponse(as, client, response); + + if (!result.id_token) { + notification.error({ + message: 'OIDC: Proccess Authorization Code Grant Response error', + placement: 'bottomRight' + }); + logout(); + navigate(paths.login); + return; + } + + onLogin(result.id_token, result.refresh_token); + navigate(searchParams.get(redirectToQueryParam) || paths.home); + } catch (err) { notification.error({ - message: 'OIDC: Proccess Authorization Code Grant Response error', + message: `OIDC: ${JSON.stringify(err)}`, placement: 'bottomRight' }); + logout(); navigate(paths.login); - return; } - - onLogin(result.id_token, result.refresh_token); - navigate(searchParams.get(redirectToQueryParam) || paths.home); })(); }, [as, client]);