From fadcd393566c4679571f5da695c4f1748bf88756 Mon Sep 17 00:00:00 2001 From: Luigi Marini Date: Mon, 21 Nov 2022 12:29:19 -0600 Subject: [PATCH] Delete bad JWT token after attempting a refresh to avoid 403 on OPTION /refresh_token. This was happening when the JWT token expired and we were trying to refresh it. It would result in a redirect to always the main page instead of the page we were on. --- frontend/src/actions/common.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/actions/common.js b/frontend/src/actions/common.js index 15323c9c2..533a28e02 100644 --- a/frontend/src/actions/common.js +++ b/frontend/src/actions/common.js @@ -32,8 +32,6 @@ export function handleErrors(reason, originalFunc){ if (reason.status === 401){ const headers = {"Authorization": cookies.get("Authorization")}; - V2.OpenAPI.TOKEN = undefined; - cookies.remove("Authorization", { path: "/" }); return (dispatch) => { return fetch(config.KeycloakRefresh, {method: "GET", headers: headers}) @@ -54,6 +52,9 @@ export function handleErrors(reason, originalFunc){ type: LOGOUT, receivedAt: Date.now() }); + // Delete bad JWT token + V2.OpenAPI.TOKEN = undefined; + cookies.remove("Authorization", { path: "/" }); }); }; }