spine-framework 0.3.89 → 0.3.90
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.
|
@@ -116,10 +116,11 @@ export function AppsRegistryProvider({ children }: AppsRegistryProviderProps) {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
// Fetch
|
|
119
|
+
// Fetch when user identity or roles change (roles may update after registration)
|
|
120
|
+
const rolesKey = user?.roles?.join(',') || ''
|
|
120
121
|
useEffect(() => {
|
|
121
122
|
fetchApps()
|
|
122
|
-
}, [user?.id, user?.account_id])
|
|
123
|
+
}, [user?.id, user?.account_id, rolesKey])
|
|
123
124
|
|
|
124
125
|
const routableApps = apps.filter(
|
|
125
126
|
app => app.route_prefix != null && app.renderer !== 'none'
|
|
@@ -269,9 +269,20 @@ export function AuthProvider({ children }: AuthProviderProps) {
|
|
|
269
269
|
// Check initial auth state
|
|
270
270
|
const checkAuth = async () => {
|
|
271
271
|
try {
|
|
272
|
-
//
|
|
272
|
+
// If user is loaded from sessionStorage, skip the loading state but
|
|
273
|
+
// still refresh context in the background to pick up role changes
|
|
273
274
|
if (user) {
|
|
274
|
-
console.log('User already loaded,
|
|
275
|
+
console.log('User already loaded, refreshing context in background:', user.id)
|
|
276
|
+
const { data: { session } } = await supabase.auth.getSession()
|
|
277
|
+
if (session?.user) {
|
|
278
|
+
const userContext = await fetchUserContext()
|
|
279
|
+
if (userContext) {
|
|
280
|
+
setUserWithStorage(userContext)
|
|
281
|
+
setAccountId(userContext.account_id)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
setIsLoading(false)
|
|
285
|
+
console.log('Auth check completed, loading set to false')
|
|
275
286
|
return
|
|
276
287
|
}
|
|
277
288
|
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
import React, { useState, useEffect, useCallback } from 'react'
|
|
35
35
|
import { Link, useNavigate, useSearchParams } from 'react-router-dom'
|
|
36
36
|
import { LoadingSpinner } from '../../components/ui/LoadingSpinner'
|
|
37
|
+
import { useAuth } from '../../contexts/AuthContext'
|
|
37
38
|
import { supabase } from '../../lib/supabase'
|
|
38
39
|
|
|
39
40
|
// ─── TYPES ────────────────────────────────────────────────────────────────────
|
|
@@ -132,6 +133,7 @@ function getPostRegistrationRedirect(
|
|
|
132
133
|
export function RegisterPage() {
|
|
133
134
|
const [searchParams] = useSearchParams()
|
|
134
135
|
const navigate = useNavigate()
|
|
136
|
+
const { refreshUser } = useAuth()
|
|
135
137
|
const inviteToken = searchParams.get('t')
|
|
136
138
|
|
|
137
139
|
// Registration config
|
|
@@ -342,6 +344,10 @@ export function RegisterPage() {
|
|
|
342
344
|
return
|
|
343
345
|
}
|
|
344
346
|
|
|
347
|
+
// Re-fetch user context so roles are populated (complete-registration
|
|
348
|
+
// sets role_id, but the initial auth fetch may have raced ahead of it)
|
|
349
|
+
await refreshUser()
|
|
350
|
+
|
|
345
351
|
// Navigate to configured post-registration destination
|
|
346
352
|
const redirectPath = getPostRegistrationRedirect(regConfig, searchParams, false)
|
|
347
353
|
navigate(redirectPath, { replace: true })
|