Fix redirect loop for users who need to set password
Build and Push Docker Image / build (push) Successful in 8m19s
Details
Build and Push Docker Image / build (push) Successful in 8m19s
Details
The auth layout was redirecting logged-in users to their dashboard even when they still needed to set their password. This caused a redirect loop: auth layout redirects to /jury, middleware redirects back to /set-password, repeat until crash. Now the auth layout checks mustSetPassword before redirecting, allowing users to complete the password setup flow. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
0f956cf23f
commit
a3cc73e49d
|
|
@ -16,7 +16,8 @@ export default async function AuthLayout({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect logged-in users to their dashboard
|
// Redirect logged-in users to their dashboard
|
||||||
if (session?.user) {
|
// But NOT if they still need to set their password
|
||||||
|
if (session?.user && !session.user.mustSetPassword) {
|
||||||
const role = session.user.role
|
const role = session.user.role
|
||||||
if (role === 'SUPER_ADMIN' || role === 'PROGRAM_ADMIN') {
|
if (role === 'SUPER_ADMIN' || role === 'PROGRAM_ADMIN') {
|
||||||
redirect('/admin')
|
redirect('/admin')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue