Fix stale session redirect loop, filtering stats to reflect overrides
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m56s
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m56s
- Auth layout verifies user exists in DB before redirecting to dashboard, breaking infinite loop for deleted accounts with stale sessions - Jury/Mentor layouts handle null user (deleted) by redirecting to login - Filtering stats cards and result list now use effective outcome (finalOutcome ?? outcome) instead of raw AI outcome - Award eligibility evaluation includes admin-overridden PASSED projects - Award shortlist reasoning column shows full text instead of truncating Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { redirect } from 'next/navigation'
|
||||
import Image from 'next/image'
|
||||
import { auth } from '@/lib/auth'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
|
||||
export default async function AuthLayout({
|
||||
children,
|
||||
@@ -18,16 +19,25 @@ export default async function AuthLayout({
|
||||
// Redirect logged-in users to their dashboard
|
||||
// But NOT if they still need to set their password
|
||||
if (session?.user && !session.user.mustSetPassword) {
|
||||
const role = session.user.role
|
||||
if (role === 'SUPER_ADMIN' || role === 'PROGRAM_ADMIN') {
|
||||
redirect('/admin')
|
||||
} else if (role === 'JURY_MEMBER') {
|
||||
redirect('/jury')
|
||||
} else if (role === 'OBSERVER') {
|
||||
redirect('/observer')
|
||||
} else if (role === 'MENTOR') {
|
||||
redirect('/mentor')
|
||||
// Verify user still exists in DB (handles deleted accounts with stale sessions)
|
||||
const dbUser = await prisma.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
select: { id: true },
|
||||
})
|
||||
|
||||
if (dbUser) {
|
||||
const role = session.user.role
|
||||
if (role === 'SUPER_ADMIN' || role === 'PROGRAM_ADMIN') {
|
||||
redirect('/admin')
|
||||
} else if (role === 'JURY_MEMBER') {
|
||||
redirect('/jury')
|
||||
} else if (role === 'OBSERVER') {
|
||||
redirect('/observer')
|
||||
} else if (role === 'MENTOR') {
|
||||
redirect('/mentor')
|
||||
}
|
||||
}
|
||||
// If user doesn't exist in DB, fall through and show auth page
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user