File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed
Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -65,19 +65,15 @@ export function checkToken<F extends Func<any, any>>(
6565 method : F
6666) : Func < Promise < ReturnType < F > > , Parameters < F > > {
6767 return async ( ...args : any [ ] ) => {
68- try {
69- const { error } = await apiClient . GET ( '/auth/me' ) ;
70- throw error ;
71- } catch ( err ) {
72- const error = err as apiError ;
73- if ( error && error . message === 'Forbidden' ) {
74- const { deleteToken } = useProfileStore ( ) ;
75- const toastStore = useToastStore ( ) ;
76- deleteToken ( ) ;
77- router . push ( '/auth' ) ;
78- toastStore . push ( { title : 'Сессия истекла' } ) ;
79- }
68+ const { response : checkResponse } = await apiClient . GET ( '/auth/me' ) ;
69+ if ( ! checkResponse . ok && checkResponse . status === 403 ) {
70+ const { deleteToken } = useProfileStore ( ) ;
71+ const toastStore = useToastStore ( ) ;
72+ deleteToken ( ) ;
73+ router . push ( '/auth' ) ;
74+ toastStore . push ( { title : 'Сессия истекла' } ) ;
8075 }
76+
8177 const response = await method ( ...args ) ;
8278 return response ;
8379 } ;
Original file line number Diff line number Diff line change @@ -69,7 +69,12 @@ export const authHandler: NavigationGuard = async to => {
6969 session_name : navigator . userAgent ?? UNKNOWN_DEVICE ,
7070 } ,
7171 } )
72- : await apiClient . POST ( `/auth/${ methodLink } /login` , { body : { ...to . query } } ) ;
72+ : await apiClient . POST ( `/auth/${ methodLink } /login` , {
73+ body : {
74+ ...to . query ,
75+ session_name : navigator . userAgent ?? UNKNOWN_DEVICE ,
76+ } ,
77+ } ) ;
7378
7479 if ( response . ok && data ?. token ) {
7580 LocalStorage . set ( LocalStorageItem . Token , data . token ) ;
You can’t perform that action at this time.
0 commit comments