File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -190,21 +190,21 @@ class AuthManager {
190190 }
191191
192192 // Check Session
193- async checkSession ( ) {
194193 const { data : { session } } = await this . db . auth . getSession ( ) ;
195- if ( ! session ) return null ;
196-
197- const profile = await this . getUserProfile ( session . user . id ) ;
198- this . currentUser = session . user ;
194+ if ( session ) {
195+ const profile = await this . getUserProfile ( session . user . id ) ;
196+ this . currentUser = session . user ;
197+ this . userProfile = profile ;
198+ return { session, profile } ;
199+ }
200+ const token = localStorage . getItem ( "simpatico_token" ) ;
201+ const user = JSON . parse ( localStorage . getItem ( "simpatico_user" ) || "{}" ) ;
202+ if ( ! token || ! user . id ) return null ;
203+ const profile = await this . getUserProfile ( user . id ) ;
204+ if ( ! profile ) return null ;
205+ this . currentUser = user ;
199206 this . userProfile = profile ;
200- return { session, profile } ;
201- }
202-
203- // Logout
204- async logout ( ) {
205- await this . db . auth . signOut ( ) ;
206- window . location . href = '/auth/login.html' ;
207- }
207+ return { session : { user } , profile } ;
208208
209209 // Redirect by Role
210210 redirectByRole ( role ) {
You can’t perform that action at this time.
0 commit comments