Skip to content

Commit

Permalink
IPK-78 refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben committed Jan 1, 2024
1 parent ac26263 commit b7d2781
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function middleware(req: NextRequest) {
return NextResponse.redirect(new URL("/login", req.url));
}
try {
if (req.nextUrl.pathname.startsWith("/admin") && user?.role !== "ADMIN") {
if (req.nextUrl.pathname.startsWith("/admin") && user && "role" in user && user?.role !== "ADMIN") {
return NextResponse.redirect(new URL("/unauthorized", req.url));
}

Expand Down

0 comments on commit b7d2781

Please sign in to comment.