feat: integrate coaching frameworks, Eisenhower matrix, Gantt chart, and Goal Validation test
This commit is contained in:
@@ -12,9 +12,11 @@ interface User {
|
||||
export const useAuth = () => {
|
||||
const token = useCookie<string | null>('xflow_token', {
|
||||
maxAge: 60 * 60 * 24 * 7,
|
||||
sameSite: 'strict'
|
||||
sameSite: 'lax'
|
||||
})
|
||||
|
||||
const isInitializing = useState('auth_initializing', () => true)
|
||||
|
||||
const user = computed<User | null>(() => {
|
||||
if (!token.value) return null
|
||||
try {
|
||||
@@ -55,8 +57,10 @@ export const useAuth = () => {
|
||||
}
|
||||
|
||||
const initAuth = () => {
|
||||
if (process.server) return
|
||||
|
||||
const auth = getAuth()
|
||||
onAuthStateChanged(auth, async (firebaseUser) => {
|
||||
const unsubscribe = onAuthStateChanged(auth, async (firebaseUser) => {
|
||||
// If user is authenticated in Firebase but we lost our backend token, try to restore
|
||||
if (firebaseUser && !token.value) {
|
||||
try {
|
||||
@@ -68,13 +72,15 @@ export const useAuth = () => {
|
||||
token.value = res.token
|
||||
|
||||
if (useRoute().path === '/login') {
|
||||
navigateTo('/')
|
||||
await navigateTo('/')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to restore backend auth from Firebase', e)
|
||||
}
|
||||
}
|
||||
isInitializing.value = false
|
||||
})
|
||||
return unsubscribe
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -82,6 +88,7 @@ export const useAuth = () => {
|
||||
user,
|
||||
isAuthenticated,
|
||||
isAdmin,
|
||||
isInitializing,
|
||||
googleSignIn,
|
||||
logout,
|
||||
initAuth
|
||||
|
||||
Reference in New Issue
Block a user