chore: update various components and services for improved functionality and consistency, including formatting adjustments and minor refactors

This commit is contained in:
Julien Froidefond
2025-12-07 09:54:05 +01:00
parent 4f5724c0ff
commit 39e3328123
141 changed files with 5292 additions and 3243 deletions

View File

@@ -3,7 +3,7 @@ import type { UserData } from "@/lib/services/auth-server.service";
export async function getCurrentUser(): Promise<UserData | null> {
const session = await auth();
if (!session?.user) {
return null;
}
@@ -23,14 +23,14 @@ export async function isAdmin(): Promise<boolean> {
export async function requireAdmin(): Promise<UserData> {
const user = await getCurrentUser();
if (!user) {
throw new Error("Unauthenticated");
}
if (!user.roles.includes("ROLE_ADMIN")) {
throw new Error("Forbidden: Admin access required");
}
return user;
}