-
Notifications
You must be signed in to change notification settings - Fork 0
/
middleware.js
44 lines (33 loc) · 1.2 KB
/
middleware.js
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
35
36
37
38
39
40
41
42
43
44
// import { getToken } from "next-auth/jwt";
// import { NextResponse } from "next/server";
// export async function middleware(req) {
// const token = await getToken({ req, secret: process.env.JWT_SECRET });
// const isPath= path==='/'
// // If no token, redirect to the home page
// if (!token) {
// console.log("No token found, redirecting to home page");
// return NextResponse.redirect(new URL('/', req.url));
// }
// if(token && ){
// return NextResponse.redirect(new URL('/', req.url));
// }
// // Extract the role from the token
// const role = token._role;
// console.log("Role:", role);
// // Redirect based on the user role
// if (role === 'manager') {
// console.log("Redirecting to /manager/myteam");
// return NextResponse.redirect(new URL('/manager/myteam/squad', req.url));
// } else {
// console.log("Redirecting to home page");
// return NextResponse.redirect(new URL('/', req.url));
// }
// }
// // Apply the middleware to specific routes
// export const config = {
// matcher:[
// "/teams/:path*",
// "/manager/:path*",
// "/superadmin/:path*"
// ],
// };