feat(auth): implement role-based access control and user management features

This commit is contained in:
Nils-Johan Gynther
2026-04-18 09:34:22 +02:00
parent 20330f6410
commit c5ccef2313
22 changed files with 358 additions and 10 deletions
+30
View File
@@ -0,0 +1,30 @@
import { auth } from '../../../../auth';
import { redirect } from 'next/navigation';
import { fetchJson } from '../../../lib/api';
import UserAdminClient from './UserAdminClient';
type User = {
id: number;
username: string;
email: string;
firstName: string | null;
lastName: string | null;
role: string;
createdAt: string;
};
export default async function AdminUsersPage() {
const session = await auth();
if (!session || (session.user as any)?.role !== 'admin') {
redirect('/');
}
const users = await fetchJson<User[]>('/api/users');
return (
<main className="p-6 max-w-4xl mx-auto">
<h1 className="text-2xl font-bold mb-6">Användarhantering</h1>
<UserAdminClient users={users} currentUserId={session.user.id} />
</main>
);
}