$(document).ready(() => { const token = StorageHelper.get("access_token"); if (!token) { window.location.href = "/auth"; return; } loadProfile(); function loadProfile() { Promise.all([ Api.get("/api/auth/me"), Api.get("/api/auth/roles").catch(() => ({ roles: [] })), ]) .then(async ([user, rolesData]) => { document.title = `LiB - ${user.full_name || user.username}`; await renderProfileHeader(user); renderInfo(user); renderRoles(user.roles || [], rolesData.roles || []); $("#account-section, #roles-section").removeClass("hidden"); }) .catch((error) => { console.error(error); Utils.showToast("Ошибка загрузки профиля", "error"); }); } async function renderProfileHeader(user) { const avatarUrl = await Utils.getGravatarUrl(user.email); const displayName = Utils.escapeHtml(user.full_name || user.username); $("#profile-card").html(`
@${Utils.escapeHtml(user.username)}
${user.is_active ? "Активен" : "Заблокирован"}Нет ролей
'); return; } const roleMap = {}; allRoles.forEach((r) => (roleMap[r.name] = r.description)); const html = userRoles .map( (role) => `