1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-07-06 17:30:10 +02:00

fix: error when refresh token is expired

This commit is contained in:
Elias Schneider 2022-10-11 14:44:12 +02:00
parent 237733b53f
commit 0823d28e23

View File

@ -20,8 +20,8 @@ const signOut = () => {
}; };
const refreshAccessToken = async () => { const refreshAccessToken = async () => {
try {
const currentAccessToken = getCookie("access_token") as string; const currentAccessToken = getCookie("access_token") as string;
if ( if (
currentAccessToken && currentAccessToken &&
(jose.decodeJwt(currentAccessToken).exp ?? 0) * 1000 < (jose.decodeJwt(currentAccessToken).exp ?? 0) * 1000 <
@ -32,6 +32,9 @@ const refreshAccessToken = async () => {
const response = await api.post("auth/token", { refreshToken }); const response = await api.post("auth/token", { refreshToken });
setCookies("access_token", response.data.accessToken); setCookies("access_token", response.data.accessToken);
} }
} catch {
console.info("Refresh token invalid or expired");
}
}; };
export default { export default {