From fa04f70b32219c1e65295272b4c807217bec47b7 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Mon, 11 Mar 2024 19:26:16 -0300 Subject: [PATCH] bugfix: login on loop when username or password is incorrect --- src/frontend/src/controllers/API/api.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/controllers/API/api.tsx b/src/frontend/src/controllers/API/api.tsx index c64d8df07..0ad67cecb 100644 --- a/src/frontend/src/controllers/API/api.tsx +++ b/src/frontend/src/controllers/API/api.tsx @@ -24,7 +24,10 @@ function ApiInterceptor() { async (error: AxiosError) => { if (error.response?.status === 403 || error.response?.status === 401) { if (!autoLogin) { - checkErrorCount(); + const stillRefresh = checkErrorCount(); + if (!stillRefresh) { + return Promise.reject(error); + } const acceptedRequest = await tryToRenewAccessToken(error); const accessToken = cookies.get("access_token_lf"); @@ -96,7 +99,10 @@ function ApiInterceptor() { if (authenticationErrorCount > 3) { authenticationErrorCount = 0; logout(); + return false; } + + return true; } async function tryToRenewAccessToken(error: AxiosError) { @@ -116,6 +122,7 @@ function ApiInterceptor() { } catch (error) { clearBuildVerticesState(error); logout(); + return Promise.reject("Authentication error"); } }