-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmiddleware.ts
32 lines (28 loc) · 1.01 KB
/
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
32
// import { auth } from "@/utils/auth"
export { default } from "next-auth/middleware"
// export default auth((req) => {
// if (!req.auth) {
// const url = req.url.replace(req.nextUrl.pathname, "/login")
// return Response.redirect(url)
// }
// if (req.nextUrl.pathname === "/settings" || req.nextUrl.pathname === "/reports") {
// if (req.auth.user.trustLevel !== 2) {
// return Response.redirect("/")
// }
// }
// })
// 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
// console.log(token)
// if (req.nextUrl.pathname === '/settings') {
// return token?.user.trustLevel === 2
// }
// // `/me` only requires the user to be logged in
// return !!token
// }
// }
// })
export const config = { matcher: ['/classes', '/classes(.*)', '/settings', '/leaderboard', '/auditlogs', '/reports'] }