spine-framework 0.3.90 → 0.3.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -163,8 +163,10 @@ export function AuthProvider({ children }: AuthProviderProps) {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
const
|
|
167
|
-
const [
|
|
166
|
+
const storedUser = getStoredUser()
|
|
167
|
+
const [user, setUser] = useState<User | null>(storedUser)
|
|
168
|
+
// If we have a stored user, start loading to verify context before rendering routes
|
|
169
|
+
const [isLoading, setIsLoading] = useState(!!storedUser)
|
|
168
170
|
const [isLoggingIn, setIsLoggingIn] = useState(false)
|
|
169
171
|
|
|
170
172
|
// Save user to sessionStorage whenever it changes
|
|
@@ -269,10 +271,10 @@ export function AuthProvider({ children }: AuthProviderProps) {
|
|
|
269
271
|
// Check initial auth state
|
|
270
272
|
const checkAuth = async () => {
|
|
271
273
|
try {
|
|
272
|
-
// If user is loaded from sessionStorage,
|
|
273
|
-
//
|
|
274
|
+
// If user is loaded from sessionStorage, verify context from server
|
|
275
|
+
// before rendering routes (isLoading starts true in this case)
|
|
274
276
|
if (user) {
|
|
275
|
-
console.log('User
|
|
277
|
+
console.log('User loaded from storage, verifying context:', user.id)
|
|
276
278
|
const { data: { session } } = await supabase.auth.getSession()
|
|
277
279
|
if (session?.user) {
|
|
278
280
|
const userContext = await fetchUserContext()
|
|
@@ -280,13 +282,15 @@ export function AuthProvider({ children }: AuthProviderProps) {
|
|
|
280
282
|
setUserWithStorage(userContext)
|
|
281
283
|
setAccountId(userContext.account_id)
|
|
282
284
|
}
|
|
285
|
+
} else {
|
|
286
|
+
// Session expired — clear stored user
|
|
287
|
+
setUserWithStorage(null)
|
|
288
|
+
setAccountId(null)
|
|
283
289
|
}
|
|
284
|
-
setIsLoading(false)
|
|
285
|
-
console.log('Auth check completed, loading set to false')
|
|
286
290
|
return
|
|
287
291
|
}
|
|
288
292
|
|
|
289
|
-
//
|
|
293
|
+
// No stored user — show loading spinner while checking
|
|
290
294
|
setIsLoading(true)
|
|
291
295
|
console.log('Checking initial auth state...')
|
|
292
296
|
const { data: { session } } = await supabase.auth.getSession()
|