File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { createAsyncThunk } from '@reduxjs/toolkit';
2
2
3
3
import { type AuthMode } from '~/libs/enums/enums.js' ;
4
4
import { getErrorMessage } from '~/libs/helpers/helpers.js' ;
5
- import { type HttpError } from '~/libs/packages/http/http.js' ;
5
+ import { type HttpError , HttpCode } from '~/libs/packages/http/http.js' ;
6
6
import { StorageKey } from '~/libs/packages/storage/storage.js' ;
7
7
import { type AsyncThunkConfig , type ValueOf } from '~/libs/types/types.js' ;
8
8
import {
@@ -71,7 +71,12 @@ const getCurrent = createAsyncThunk<
71
71
return await authApi . getCurrentUser ( ) ;
72
72
} catch ( error ) {
73
73
notification . warning ( getErrorMessage ( error ) ) ;
74
- await localStorage . drop ( StorageKey . TOKEN ) ;
74
+
75
+ const httpError = error as HttpError ;
76
+
77
+ if ( httpError . status === HttpCode . UNAUTHORIZED ) {
78
+ await localStorage . drop ( StorageKey . TOKEN ) ;
79
+ }
75
80
throw error ;
76
81
}
77
82
} ) ;
You can’t perform that action at this time.
0 commit comments