From ab4cde1ce28328baeccf82347e58972d1fbaaa3a Mon Sep 17 00:00:00 2001 From: xEsiah Date: Tue, 10 Nov 2026 21:28:49 +0100 Subject: [PATCH] fix(server): version CRM de backend/shared (suppression des roles) --- backend/shared/src/auth.ts | 17 +---------------- backend/shared/src/index.ts | 1 - 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/backend/shared/src/auth.ts b/backend/shared/src/auth.ts index aa1e58d..18f3173 100644 --- a/backend/shared/src/auth.ts +++ b/backend/shared/src/auth.ts @@ -61,8 +61,6 @@ export interface SessionUser { email: string; first_name: string; last_name: string; - role_slug: string; - role_name: string; is_active: number; must_change_password: number; } @@ -106,12 +104,10 @@ export const createSession = async ( export const resolveSession = async (db: Db, token: string): Promise => { const row = await db.one( `SELECT u.id, u.email, u.first_name, u.last_name, - r.slug AS role_slug, r.name AS role_name, u.is_active, u.must_change_password, s.last_seen_at FROM user_sessions s JOIN users u ON u.id = s.user_id - JOIN roles r ON r.id = u.role_id WHERE s.token_hash = ? AND s.revoked_at IS NULL AND s.expires_at > UTC_TIMESTAMP() @@ -205,18 +201,7 @@ export const requireAuth = async (context: Context, next: Next): Promise = await next(); }; -/** Le role est impose en base, jamais en entete, donc ni cacheable ni falsifiable. */ -export const requireRole = - (...slugs: string[]) => - async (context: Context, next: Next): Promise => { - const user = context.get("user") as SessionUser | undefined; - if (!user) throw AppError.unauthorized(); - if (!slugs.includes(user.role_slug)) { - throw AppError.forbidden(`Action reservee au role : ${slugs.join(", ")}.`); - } - await next(); - }; - +/** Le role n'existe plus : tout compte authentifie a les memes droits. */ export const currentUser = (context: Context): SessionUser => { const user = context.get("user") as SessionUser | undefined; if (!user) throw AppError.unauthorized(); diff --git a/backend/shared/src/index.ts b/backend/shared/src/index.ts index 1161d37..9dc7eb7 100644 --- a/backend/shared/src/index.ts +++ b/backend/shared/src/index.ts @@ -24,7 +24,6 @@ export { isHttpsRequest, hashPassword, requireAuth, - requireRole, purgeExpiredSessions, revokeSession, SESSION_COOKIE,