Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
StephDietz committed Sep 22, 2023
1 parent c610bf7 commit 57a987e
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions dashboard/15-final/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
import { withAuth } from 'next-auth/middleware';

// export default withAuth(
// // `withAuth` augments your `Request` with the user's token.
// function middleware(req) {
// const session = req.cookies.has('next-auth.session-token');

// if (
// session &&
// (req.nextUrl.pathname.startsWith('/login') || req.url.includes('/login'))
// ) {
// return NextResponse.redirect(new URL('/dashboard', req.url));
// }

// if (!session && req.nextUrl.pathname.startsWith('/dashboard')) {
// return NextResponse.redirect(new URL('/login', req.url));
// }
// return NextResponse.next();
// },
// );

// export const config = { matcher: ['/:path*'] };

export async function middleware(request: NextRequest) {
const session = request.cookies.has('next-auth.session-token');

// const session = request.cookies.has('next-auth.session-token');
const session = true;
if (
session &&
(request.nextUrl.pathname.startsWith('/login') ||
Expand All @@ -39,4 +17,3 @@ export async function middleware(request: NextRequest) {
}
return NextResponse.next();
}
export const config = { matcher: ['/:path*'] };

0 comments on commit 57a987e

Please sign in to comment.