-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiddleware.ts
More file actions
34 lines (25 loc) · 830 Bytes
/
Copy pathmiddleware.ts
File metadata and controls
34 lines (25 loc) · 830 Bytes
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
33
34
import { withAuth } from 'next-auth/middleware';
import { NextResponse } from 'next/server';
export default withAuth(function middleware(req) {
// console.log(req.nextUrl.pathname);
// console.log(req.nextauth.token!.role);
// if (req.nextUrl.pathname.startsWith("/lecturer") &&
// req.nextauth.token!.role != "lecturer"
// ) {
// return NextResponse.rewrite(new URL("/Denided", req.url))
// }
// if (req.nextUrl.pathname.startsWith("/admin") &&
// req.nextauth.token!.role != "admin"
// ) {
// return NextResponse.rewrite(new URL("/Denided", req.url))
// }
// },
// {
// callbacks: {
// authorized: ({ token }) => !!token,
// },
}
);
// export const config = {
// matcher: ['/admin/:path*', '/lecturer/:path*'],
// }