feat(auth): implement role-based access control and user management features
This commit is contained in:
@@ -17,6 +17,14 @@ export default auth((req) => {
|
||||
return NextResponse.redirect(loginUrl);
|
||||
}
|
||||
|
||||
// Admin-sidor kräver admin-roll
|
||||
if (pathname.startsWith('/admin')) {
|
||||
const role = (req.auth.user as any)?.role;
|
||||
if (role !== 'admin') {
|
||||
return NextResponse.redirect(new URL('/', req.url));
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user