Website : rimsha.abasa.com
backdoor
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
talha_silentcontent
/
src
/
Filename :
middleware.ts
back
Copy
import { NextResponse } from 'next/server'; import type { NextRequest } from 'next/server'; import jwt from 'jsonwebtoken'; // Import the 'jsonwebtoken' library export function middleware(request: NextRequest) { const path = request.nextUrl.pathname; const isPublicPath = path === '/signin' || path === '/signup'; const token = request.cookies.get('token')?.value || ''; if (isPublicPath && token) { return NextResponse.redirect(new URL('/dashboard', request.nextUrl)); } if (!isPublicPath && !token) { return NextResponse.redirect(new URL('/signin', request.nextUrl)); } // // Check if the token is expired // if (!isPublicPath && token) { // try { // const decodedToken = jwt.verify(token, process.env.TOKEN_SECRET!); // Replace with your actual secret key // const expirationTime = decodedToken.exp * 1000; // Convert expiration time to milliseconds // if (expirationTime <= Date.now()) { // // Token has expired, redirect to login // request.cookies.set('token', '', { maxAge: 0 }); // return NextResponse.redirect(new URL('/signin', request.nextUrl)); // } // } catch (error) { // // Token verification failed, redirect to login // request.cookies.set('token', '', { maxAge: 0 }); // return NextResponse.redirect(new URL('/signin', request.nextUrl)); // } // } } // See "Matching Paths" below to learn more export const config = { matcher: [ '/signout', '/signin', '/signup', '/dashboard', '/articles', '/articles/:path*', '/organizations', '/organizations/:path*', '/batches', '/batches/:path*', '/settings', '/settings/:path*', ], };