Skip to content

Commit

Permalink
fix(auth): token renew failure (akuity#3122)
Browse files Browse the repository at this point in the history
Signed-off-by: Mayursinh Sarvaiya <[email protected]>
Signed-off-by: Diego Caspi <[email protected]>
  • Loading branch information
Marvin9 authored and diegocaspi committed Dec 18, 2024
1 parent d5f698e commit cfcf3cf
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions ui/src/features/auth/token-renew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit cfcf3cf

Please sign in to comment.