fix issues
This commit is contained in:
@@ -31,15 +31,31 @@ export function middleware(request: NextRequest) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// Public routes are always accessible
|
||||
if (isPublicRoute(pathname)) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// Check for authentication cookie
|
||||
const cookies = request.cookies;
|
||||
const hasAuthCookie = cookies.has('gp_session');
|
||||
|
||||
// Public routes are always accessible
|
||||
if (isPublicRoute(pathname)) {
|
||||
// Special handling for auth routes - redirect authenticated users away
|
||||
const authRoutes = [
|
||||
'/auth/login',
|
||||
'/auth/signup',
|
||||
'/auth/forgot-password',
|
||||
'/auth/reset-password',
|
||||
'/auth/iracing',
|
||||
'/auth/iracing/start',
|
||||
'/auth/iracing/callback',
|
||||
];
|
||||
|
||||
if (authRoutes.includes(pathname) && hasAuthCookie) {
|
||||
// User is authenticated and trying to access auth page, redirect to dashboard
|
||||
return NextResponse.redirect(new URL('/dashboard', request.url));
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// In demo/alpha mode, allow access if session cookie exists
|
||||
if (mode === 'alpha' && hasAuthCookie) {
|
||||
return NextResponse.next();
|
||||
|
||||
Reference in New Issue
Block a user