Skip to content

Commit fa586a0

Browse files
IshaanXCoderAbhishek
authored andcommitted
fix/multiple-error-messages (intelowlproject#3291)
1 parent d08e36c commit fa586a0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

frontend/src/stores/useAuthStore.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const CSRF_TOKEN = "csrftoken";
1212
// hook/ store see: https://github.com/pmndrs/zustand
1313
export const useAuthStore = create((set, get) => ({
1414
loading: false,
15+
1516
CSRFToken: Cookies.get(CSRF_TOKEN) || "",
1617
user: {
1718
username: "",
@@ -36,6 +37,9 @@ export const useAuthStore = create((set, get) => ({
3637
access: resp.data.access,
3738
});
3839
} catch (err) {
40+
if (err?.response?.status === 401) {
41+
return;
42+
}
3943
addToast(
4044
"Error fetching user access information!",
4145
err.parsedMsg,
@@ -76,14 +80,18 @@ export const useAuthStore = create((set, get) => ({
7680
.catch(onLogoutCb);
7781
},
7882
forceLogout: () => {
83+
if (get().loading) {
84+
return;
85+
}
86+
set({ loading: true });
7987
addToast(
8088
"Invalid token. You will be logged out shortly",
8189
null,
8290
"spinner",
8391
true,
8492
1000,
8593
);
86-
return setTimeout(get().service.logoutUser, 500);
94+
setTimeout(get().service.logoutUser, 500);
8795
},
8896
changePassword: async (values) => {
8997
try {

0 commit comments

Comments
 (0)