File tree 1 file changed +2
-2
lines changed
1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { axiosInstance } from '@/interceptors' ;
2
2
import { IUser } from '@/interfaces/IUser' ;
3
3
import { validateToken } from '@/utils' ;
4
+ import { getCookie } from 'cookies-next' ;
4
5
import { cookies } from 'next/dist/client/components/headers' ;
5
6
6
7
const userEmpty : IUser = {
@@ -73,7 +74,7 @@ export async function getUserFromServer(): Promise<IUser> {
73
74
}
74
75
75
76
export async function getUserFromClient ( ) : Promise < IUser > {
76
- const token = localStorage . getItem ( 'token' ) ;
77
+ const token = getCookie ( 'token' ) ;
77
78
78
79
if ( ! token ) {
79
80
return userEmpty ;
@@ -82,7 +83,6 @@ export async function getUserFromClient(): Promise<IUser> {
82
83
const payload = await validateToken ( token ) ;
83
84
84
85
if ( ! payload || ! isValidUser ( payload . user ) ) {
85
- localStorage . removeItem ( 'token' ) ;
86
86
return userEmpty ;
87
87
}
88
88
You can’t perform that action at this time.
0 commit comments