catches JSON.parse possible error in oauth2 identity token field (#4709)

This commit is contained in:
Dimitri Mitropoulos 2022-04-20 06:32:35 -04:00 committed by GitHub
parent 7e209fa20a
commit a5a1be23d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -299,19 +299,22 @@ const renderIdentityTokenExpiry = (token?: Pick<OAuth2Token, 'identityToken'>) =
return;
}
const { exp } = JSON.parse(decodedString);
if (!exp) {
return '(never expires)';
try {
const { exp } = JSON.parse(decodedString);
if (!exp) {
return '(never expires)';
}
const convertedExp = convertEpochToMilliseconds(exp);
return (
<span>
&#x28;expires <TimeFromNow timestamp={convertedExp} />
&#x29;
</span>
);
} catch (error) {
console.error(error);
return '';
}
const convertedExp = convertEpochToMilliseconds(exp);
return (
<span>
&#x28;expires <TimeFromNow timestamp={convertedExp} />
&#x29;
</span>
);
};
const renderAccessTokenExpiry = (token?: Pick<OAuth2Token, 'accessToken' | 'expiresAt'>) => {