bugfix: login on loop when username or password is incorrect

This commit is contained in:
cristhianzl 2024-03-11 19:26:16 -03:00
commit fa04f70b32

View file

@ -24,7 +24,10 @@ function ApiInterceptor() {
async (error: AxiosError) => { async (error: AxiosError) => {
if (error.response?.status === 403 || error.response?.status === 401) { if (error.response?.status === 403 || error.response?.status === 401) {
if (!autoLogin) { if (!autoLogin) {
checkErrorCount(); const stillRefresh = checkErrorCount();
if (!stillRefresh) {
return Promise.reject(error);
}
const acceptedRequest = await tryToRenewAccessToken(error); const acceptedRequest = await tryToRenewAccessToken(error);
const accessToken = cookies.get("access_token_lf"); const accessToken = cookies.get("access_token_lf");
@ -96,7 +99,10 @@ function ApiInterceptor() {
if (authenticationErrorCount > 3) { if (authenticationErrorCount > 3) {
authenticationErrorCount = 0; authenticationErrorCount = 0;
logout(); logout();
return false;
} }
return true;
} }
async function tryToRenewAccessToken(error: AxiosError) { async function tryToRenewAccessToken(error: AxiosError) {
@ -116,6 +122,7 @@ function ApiInterceptor() {
} catch (error) { } catch (error) {
clearBuildVerticesState(error); clearBuildVerticesState(error);
logout(); logout();
return Promise.reject("Authentication error");
} }
} }