-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.config.ts
More file actions
23 lines (22 loc) · 829 Bytes
/
auth.config.ts
File metadata and controls
23 lines (22 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { NextAuthConfig } from "next-auth"
export const authConfig = {
pages: {
signIn: "/login",
},
callbacks: {
authorized({ auth, request: { nextUrl } }) {
const isLoggedIn = !!auth?.user
const isOnDashboard = nextUrl.pathname.startsWith("/dashboard")
if (isOnDashboard) {
if (isLoggedIn) return true
return false // Redirect unauthenticated users to login page
} else if (isLoggedIn) {
// Redirect logged-in users to dashboard if they handle root or login
// but for now we'll let them stay or handle in specific page logic
return true
}
return true
},
},
providers: [], // Configured in auth.ts
} satisfies NextAuthConfig