-
Notifications
You must be signed in to change notification settings - Fork 0
/
middleware.ts
31 lines (29 loc) · 964 Bytes
/
middleware.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
29
30
31
// import { withAuth } from "next-auth/middleware"
// // More on how NextAuth.js middleware works: https://next-auth.js.org/configuration/nextjs#middleware
// export default withAuth({
// callbacks: {
// authorized({ req, token }) {
// // `/admin` requires admin role
// if (req.nextUrl.pathname === "/DataEdit") {
// return token?.role === "ADMIN"
// }
// // `/me` only requires the user to be logged in
// return !!token
// },
// },
// }
// )
// export const config = { matcher: ["/DataEdit", "/DataEdit/:path*"] }
import { withAuth } from "next-auth/middleware"
export default withAuth(
// `withAuth` augments your `Request` with the user's token.
function middleware(req) {
console.log(req.nextauth.token)
},
{
callbacks: {
authorized: ({ token }) => token?.role === "ADMIN",
},
}
)
export const config = { matcher: ["/DataEdit", "/DataEdit/:path*"] }