diff --git a/client-web/src/modules/auth/infrastructure/authApi.ts b/client-web/src/modules/auth/infrastructure/authApi.ts index babc2e9..f918efb 100644 --- a/client-web/src/modules/auth/infrastructure/authApi.ts +++ b/client-web/src/modules/auth/infrastructure/authApi.ts @@ -3,7 +3,7 @@ import type { User } from '../../../core/domain/types'; export class AuthApi { static async login(username: string, password: string) { - const response = await httpClient.request<{ accessToken: string; userId: string; username: string; displayName: string }>('/auth/login', { + const response = await httpClient.request('/auth/login', { method: 'POST', body: JSON.stringify({ username, password }), }); @@ -11,16 +11,17 @@ export class AuthApi { return { token: response.accessToken, user: { - id: response.userId, - username: response.username, + ...response, + id: response.userId || (response as any).id, + username: response.username || (response as any).userName, displayName: response.displayName, - avatar: null - } as User + avatar: response.avatar || null + } as unknown as User }; } static async register(username: string, displayName: string, password: string, bio?: string) { - const response = await httpClient.request<{ accessToken: string; userId: string; username: string; displayName: string }>('/auth/register', { + const response = await httpClient.request('/auth/register', { method: 'POST', body: JSON.stringify({ username, displayName, password, bio }), }); @@ -28,23 +29,25 @@ export class AuthApi { return { token: response.accessToken, user: { - id: response.userId, - username: response.username, + ...response, + id: response.userId || (response as any).id, + username: response.username || (response as any).userName, displayName: response.displayName, - avatar: null - } as User + avatar: response.avatar || null + } as unknown as User }; } static async getMe() { - const response = await httpClient.request<{ userId: string; username: string; displayName: string; avatar: string | null; accessToken?: string }>('/auth/me'); + const response = await httpClient.request('/auth/me'); return { user: { - id: response.userId, - username: response.username, + ...response, + id: response.userId || response.id, + username: response.username || response.userName, displayName: response.displayName, - avatar: response.avatar - } as User, + avatar: response.avatar || response.avatarUrl + } as unknown as User, token: response.accessToken }; }