import { BaseHttpClient } from "../base/http-client"; import { UserProfile } from "../../lib/types"; export class AuthClient extends BaseHttpClient { /** * Authentifie un utilisateur et créé le cookie */ async login( profile: UserProfile ): Promise<{ user: UserProfile & { uuid: string }; userUuid: string }> { return await this.post("/auth", profile); } /** * Récupère l'utilisateur actuel depuis le cookie */ async getCurrentUser(): Promise { try { const response = await this.get<{ user: UserProfile }>("/auth"); return response.user; } catch (error) { console.error("Failed to get current user:", error); return null; } } /** * Déconnecte l'utilisateur (supprime le cookie) */ async logout(): Promise { await this.delete("/auth"); } }