docs: update TEKNISK_BESKRIVNING.md to reflect changes in authentication middleware and role-based access control; remove obsolete middleware.ts file
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
import { auth } from './auth';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export default auth((req) => {
|
||||
const { pathname } = req.nextUrl;
|
||||
|
||||
if (pathname.startsWith('/admin')) {
|
||||
const role = (req.auth?.user as any)?.role;
|
||||
if (role !== 'admin') {
|
||||
const loginUrl = new URL('/login', req.url);
|
||||
loginUrl.searchParams.set('callbackUrl', pathname);
|
||||
return NextResponse.redirect(loginUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export const config = {
|
||||
matcher: ['/admin/:path*'],
|
||||
};
|
||||
Reference in New Issue
Block a user