Исправление подгрузки данных профиля
This commit is contained in:
@@ -39,16 +39,22 @@ export class AuthApi {
|
||||
}
|
||||
|
||||
static async getMe() {
|
||||
const response = await httpClient.request<any>('/auth/me');
|
||||
const authRes = await httpClient.request<any>('/auth/me');
|
||||
const userId = authRes.userId || authRes.id;
|
||||
|
||||
// Пытаемся получить расширенный профиль (био, дата рождения)
|
||||
const profileRes = await httpClient.request<any>(`/profiles/${userId}`).catch(() => ({}));
|
||||
|
||||
return {
|
||||
user: {
|
||||
...response,
|
||||
id: response.userId || response.id,
|
||||
username: response.username || response.userName,
|
||||
displayName: response.displayName,
|
||||
avatar: response.avatar || response.avatarUrl
|
||||
...authRes,
|
||||
...profileRes,
|
||||
id: userId,
|
||||
username: authRes.username || authRes.userName || profileRes.userName,
|
||||
displayName: authRes.displayName || profileRes.displayName,
|
||||
avatar: authRes.avatar || authRes.avatarUrl || profileRes.avatarUrl
|
||||
} as unknown as User,
|
||||
token: response.accessToken
|
||||
token: authRes.accessToken
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user