Skip to content

Commit

Permalink
fix: removed clear localstorage for 401 redirection. Selected local s… (
Browse files Browse the repository at this point in the history
#3384)

…torage value will be cleared
  • Loading branch information
bjp232004 committed Apr 30, 2024
1 parent 30f0988 commit b5da011
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions web/src/services/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { AxiosInstance } from "axios";
import axios from "axios";
import config from "../aws-exports";
import { Notify } from "quasar";
import { useLocalUserInfo, useLocalCurrentUser } from "@/utils/zincutils";

const http = ({ headers } = {} as any) => {
let instance: AxiosInstance;
Expand Down Expand Up @@ -56,7 +57,8 @@ const http = ({ headers } = {} as any) => {
!error.request.responseURL.includes("/auth/login")
) {
store.dispatch("logout");
localStorage.clear();
useLocalCurrentUser("", true);
useLocalUserInfo("", true);
sessionStorage.clear();
window.location.reload();
}
Expand All @@ -73,16 +75,17 @@ const http = ({ headers } = {} as any) => {
.get("/config/dex_refresh", {
//headers: { Authorization: `${refreshToken}` },
})
.then((res) => {
if (res.status === 200) {
// Token refreshed successfully, retry the original request
return instance.request(error.config);
}
.then((res) => {
if (res.status === 200) {
// Token refreshed successfully, retry the original request
return instance.request(error.config);
}
})
.catch((refreshError) => {
instance.get("/config/logout", {}).then((res) => {
store.dispatch("logout");
localStorage.clear();
useLocalCurrentUser("", true);
useLocalUserInfo("", true);
sessionStorage.clear();
window.location.reload();
return Promise.reject(refreshError);
Expand All @@ -91,7 +94,8 @@ const http = ({ headers } = {} as any) => {
} else {
if (!error.request.responseURL.includes("/login")) {
store.dispatch("logout");
localStorage.clear();
useLocalCurrentUser("", true);
useLocalUserInfo("", true);
sessionStorage.clear();
window.location.reload();
}
Expand Down

0 comments on commit b5da011

Please sign in to comment.