Fix invitation flow error by adding SessionProvider
Build and Push Docker Image / build (push) Has been cancelled
Details
Build and Push Docker Image / build (push) Has been cancelled
Details
- Add SessionProvider to root Providers for NextAuth React hooks - Add error handling to auth layout to prevent crashes on auth check failure - Add MENTOR role redirect in auth layout Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
03c031a8b6
commit
b663aae846
|
|
@ -7,7 +7,13 @@ export default async function AuthLayout({
|
|||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const session = await auth()
|
||||
let session = null
|
||||
try {
|
||||
session = await auth()
|
||||
} catch (error) {
|
||||
// Auth check failed, continue as unauthenticated
|
||||
console.error('Auth check failed in auth layout:', error)
|
||||
}
|
||||
|
||||
// Redirect logged-in users to their dashboard
|
||||
if (session?.user) {
|
||||
|
|
@ -18,6 +24,8 @@ export default async function AuthLayout({
|
|||
redirect('/jury')
|
||||
} else if (role === 'OBSERVER') {
|
||||
redirect('/observer')
|
||||
} else if (role === 'MENTOR') {
|
||||
redirect('/mentor')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { SessionProvider } from 'next-auth/react'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { httpBatchLink } from '@trpc/client'
|
||||
import superjson from 'superjson'
|
||||
|
|
@ -51,8 +52,10 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|||
)
|
||||
|
||||
return (
|
||||
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
</trpc.Provider>
|
||||
<SessionProvider>
|
||||
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
</trpc.Provider>
|
||||
</SessionProvider>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue