Skip to content

Commit e45c852

Browse files
committed
Fix checkSession localStorage fallback
1 parent 2c11599 commit e45c852

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

js/auth.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff 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) {

0 commit comments

Comments
 (0)