e# speciallyse enter a commit message to explain why this merge is

necessary,
if it merges an updated upstream into a topic branch.
This commit is contained in:
max
2026-04-17 00:42:48 +03:00

View File

@@ -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<any>('/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<any>('/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<any>('/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
};
}