From c5df5c05f1ce026aaec2d1283415178a3dfcdf47 Mon Sep 17 00:00:00 2001 From: Gitea Actions <-2+gitea-actions@noreply.localhost> Date: Fri, 16 Oct 2026 11:44:34 +0000 Subject: [PATCH] feat(header): afficher la photo de profil a la place des initiales (#6) /auth/me renvoie desormais has_avatar et avatar_updated_at (LEFT JOIN user_avatars). Le header affiche l'avatar avec un cache-buster sur updated_at, et retombe sur les initiales en cas d'absence ou d'echec. Le profil rafraichit la session apres ajout/retrait de l'avatar pour que le header se mette a jour immediatement. --------- Co-authored-by: xEsiah Reviewed-on: https://git.cohaise.dev/Esiah/CoHaiSe-CLOUD/pulls/6 Reviewed-by: Esiah Co-authored-by: Gitea Actions <-2+gitea-actions@noreply.localhost> --- backend/src/routes/auth.ts | 11 ++++++++--- frontend/src/components/AppShell.tsx | 13 ++++++++++++- frontend/src/lib/api.ts | 2 ++ frontend/src/pages/Profile.tsx | 2 ++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/backend/src/routes/auth.ts b/backend/src/routes/auth.ts index f94b5fa..b4dd8a9 100644 --- a/backend/src/routes/auth.ts +++ b/backend/src/routes/auth.ts @@ -46,6 +46,7 @@ interface UserRow { max_file_bytes: number; must_change_password: number; is_active: number; + avatar_updated_at: Date | null; } const publicUser = (row: UserRow) => ({ @@ -58,15 +59,19 @@ const publicUser = (row: UserRow) => ({ quota_bytes: row.quota_bytes, used_bytes: row.used_bytes, max_file_bytes: row.max_file_bytes, - must_change_password: row.must_change_password === 1, + must_change_password: row.must_change_password, + has_avatar: row.avatar_updated_at !== null, + avatar_updated_at: row.avatar_updated_at, }); const SELECT_USER = ` SELECT u.id, u.email, u.first_name, u.last_name, u.password_hash, r.slug AS role_slug, r.name AS role_name, - u.quota_bytes, u.used_bytes, u.max_file_bytes, u.must_change_password, u.is_active + u.quota_bytes, u.used_bytes, u.max_file_bytes, u.must_change_password, u.is_active, + ua.updated_at AS avatar_updated_at FROM users u - JOIN roles r ON r.id = u.role_id`; + JOIN roles r ON r.id = u.role_id + LEFT JOIN user_avatars ua ON ua.user_id = u.id`; export const registerAuthRoutes = (app: App, db: Db, config: Config): void => { app.use("/api/cloud/*", attachUser(db)); diff --git a/frontend/src/components/AppShell.tsx b/frontend/src/components/AppShell.tsx index 80932f9..86e427b 100644 --- a/frontend/src/components/AppShell.tsx +++ b/frontend/src/components/AppShell.tsx @@ -1,6 +1,7 @@ import { useState } from "react"; import { NavLink, Outlet } from "react-router-dom"; import { Button, cn } from "../ui/index.js"; +import { api } from "../lib/api.js"; import { useSession } from "../lib/session.js"; import { ActivityIcon, @@ -127,10 +128,20 @@ export const AppShell = () => {