File tree Expand file tree Collapse file tree
frontend/src/modules/auth Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,16 +72,7 @@ export class AuthService {
7272 }
7373
7474 static fetchMe ( ) {
75- return authAxios . get ( '/auth/me' ) . then ( ( response ) => {
76- const { data } = response ;
77- localStorage . setItem ( 'user' , JSON . stringify ( data ) ) ;
78- localStorage . setItem ( 'userDateTime' , `${ new Date ( ) . getTime ( ) } ` ) ;
79- return data ;
80- } ) ;
81- }
82-
83- static fetchMeLocally ( ) {
84- return JSON . parse ( localStorage . getItem ( 'user' ) ) ;
75+ return authAxios . get ( '/auth/me' ) . then ( ( response ) => response . data ) ;
8576 }
8677
8778 static signout ( ) {
Original file line number Diff line number Diff line change @@ -19,22 +19,8 @@ export default {
1919 try {
2020 const token = AuthToken . get ( ) ;
2121 if ( token ) {
22- const userDate = localStorage . getItem ( 'userDateTime' ) ;
23- if ( userDate ) {
24- const dateDiff = new Date ( ) . getTime ( ) - + userDate ;
25- if ( dateDiff > ( 7 * 24 * 60 * 60 * 1000 ) ) {
26- localStorage . removeItem ( 'user' ) ;
27- localStorage . removeItem ( 'userDateTime' ) ;
28- }
29- }
30- const currentUserLocally = AuthService . fetchMeLocally ( ) ;
31- connectSocket ( token ) ;
32- if ( currentUserLocally ) {
33- commit ( 'AUTH_INIT_SUCCESS' , { currentUser : currentUserLocally } ) ;
34-
35- return currentUserLocally ;
36- }
3722 const currentUser = await AuthService . fetchMe ( ) ;
23+ connectSocket ( token ) ;
3824 commit ( 'AUTH_INIT_SUCCESS' , { currentUser } ) ;
3925 return currentUser ;
4026 }
@@ -45,7 +31,6 @@ export default {
4531 } catch ( error ) {
4632 console . error ( error ) ;
4733 disconnectSocket ( ) ;
48- console . log ( error ) ;
4934 commit ( 'AUTH_INIT_ERROR' ) ;
5035 dispatch ( 'doSignout' ) ;
5136 return null ;
@@ -164,7 +149,6 @@ export default {
164149 commit ( 'AUTH_SUCCESS' , {
165150 currentUser : null ,
166151 } ) ;
167- localStorage . removeItem ( 'user' ) ;
168152 router . push ( '/auth/signin' ) ;
169153 } ,
170154
You can’t perform that action at this time.
0 commit comments