refacto time check
This commit is contained in:
parent
9308554419
commit
84dc3a7ffd
@ -19,7 +19,9 @@ export async function middleware(request: NextRequest) {
|
||||
|
||||
// If JWT expired, redirect to login page
|
||||
const token = userDecodedToken ?? customerDecodedToken;
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const currentDate = new Date();
|
||||
const time = currentDate.getTime();
|
||||
const now = Math.floor(time / 1000);
|
||||
if (token.exp < now) {
|
||||
console.log('token expired')
|
||||
return NextResponse.redirect(new URL("/login", request.url));
|
||||
|
Loading…
x
Reference in New Issue
Block a user