Title: Bugfix: Resolve Login Loop for Incorrect Username or Password (#1514)
This pull request addresses a critical bug where the login process enters into a loop when users provide incorrect credentials, specifically when the username or password is invalid. Prior to this fix, the system would repeatedly prompt users to re-enter their credentials without providing any indication of the error, leading to frustration and confusion among users.
This commit is contained in:
commit
87a2c28e22
1 changed files with 9 additions and 1 deletions
|
|
@ -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,11 +99,15 @@ function ApiInterceptor() {
|
|||
if (authenticationErrorCount > 3) {
|
||||
authenticationErrorCount = 0;
|
||||
logout();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async function tryToRenewAccessToken(error: AxiosError) {
|
||||
try {
|
||||
if (window.location.pathname.includes("/login")) return;
|
||||
const res = await renewAccessToken();
|
||||
if (res?.data?.access_token && res?.data?.refresh_token) {
|
||||
login(res?.data?.access_token);
|
||||
|
|
@ -116,6 +123,7 @@ function ApiInterceptor() {
|
|||
} catch (error) {
|
||||
clearBuildVerticesState(error);
|
||||
logout();
|
||||
return Promise.reject("Authentication error");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue