File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const CSRF_TOKEN = "csrftoken";
1212// hook/ store see: https://github.com/pmndrs/zustand
1313export 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 {
You can’t perform that action at this time.
0 commit comments