-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.config.ts
28 lines (27 loc) · 1.06 KB
/
auth.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { NextAuthConfig } from 'next-auth';
export const authConfig = {
pages: {
signIn: '/',
},
providers: [
// added later in auth.ts since it requires bcrypt which is only compatible with Node.js
// while this file is also used in non-Node.js environments
],
callbacks: {
// this is not work
// authorized({ auth, request: { nextUrl } }) {
// console.log("authorized callback");
// const isLoggedIn = !!auth?.user;
// const isOnEditOrCreatePage = nextUrl.pathname.endsWith('/edit') || nextUrl.pathname.endsWith('/create');
// console.log("isLoggedin, isOnEditOrCreatePage, nextUrl, auth", isLoggedIn, isOnEditOrCreatePage, nextUrl, auth);
// if (isOnEditOrCreatePage) {
// if (isLoggedIn) return true;
// return false; // Redirect unauthenticated users to login page
// } else if (isLoggedIn) {
// const lang = nextUrl.pathname.split('/')[1];
// return Response.redirect(new URL(`/${lang}/`, nextUrl));
// }
// return true;
// },
},
} satisfies NextAuthConfig;