51 lines
1.0 KiB
TypeScript
51 lines
1.0 KiB
TypeScript
import { BaseHttpClient } from "../base/http-client";
|
|
import { UserProfile } from "../../lib/types";
|
|
|
|
export interface LoginCredentials {
|
|
email: string;
|
|
password: string;
|
|
}
|
|
|
|
export interface RegisterData {
|
|
firstName: string;
|
|
lastName: string;
|
|
email: string;
|
|
password: string;
|
|
teamId: string;
|
|
}
|
|
|
|
export interface AuthUser {
|
|
id: string;
|
|
firstName: string;
|
|
lastName: string;
|
|
email: string;
|
|
teamId: string;
|
|
}
|
|
|
|
export class AuthClient extends BaseHttpClient {
|
|
/**
|
|
* Connecte un utilisateur avec email/password
|
|
*/
|
|
async login(
|
|
credentials: LoginCredentials
|
|
): Promise<{ user: AuthUser; message: string }> {
|
|
return await this.post("/auth/login", credentials);
|
|
}
|
|
|
|
/**
|
|
* Crée un nouveau compte utilisateur
|
|
*/
|
|
async register(
|
|
data: RegisterData
|
|
): Promise<{ user: AuthUser; message: string }> {
|
|
return await this.post("/auth/register", data);
|
|
}
|
|
|
|
/**
|
|
* Déconnecte l'utilisateur
|
|
*/
|
|
async logout(): Promise<{ message: string }> {
|
|
return await this.post("/auth/logout");
|
|
}
|
|
}
|