Fix operator login not showing error (#2185)

* Fix operator login not showing error

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Fix Test

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Daniel Valdivia
2022-07-22 10:21:25 -07:00
committed by GitHub
parent 417ea4d481
commit 9655fc4490
4 changed files with 12 additions and 6 deletions

View File

@@ -30,8 +30,12 @@ export class API {
.send(data)
.then((res) => res.body)
.catch((err) => {
// if we get unauthorized, kick out the user
if (err.status === 401 && localStorage.getItem("userLoggedIn")) {
// if we get unauthorized and we are not doing login, kick out the user
if (
err.status === 401 &&
localStorage.getItem("userLoggedIn") &&
!targetURL.includes("api/v1/login")
) {
if (window.location.pathname !== "/") {
localStorage.setItem("redirect-path", window.location.pathname);
}
@@ -41,6 +45,7 @@ export class API {
window.location.href = `${baseUrl}login`;
return;
}
return this.onError(err);
});
}

View File

@@ -62,12 +62,13 @@ export const doLoginAsync = createAsyncThunk(
loginStrategyEndpoints[loginStrategy.loginStrategy] || "/api/v1/login",
loginStrategyPayload[loginStrategy.loginStrategy]
)
.then(() => {
.then((res) => {
// We set the state in redux
dispatch(userLogged(true));
if (loginStrategy.loginStrategy === loginStrategyType.form) {
localStorage.setItem("userLoggedIn", accessKey);
}
// if it's in operator mode, check the Marketplace integration
if (isOperator) {
api
.invoke("GET", "/api/v1/mp-integration/")