This commit is contained in:
2026-05-16 02:48:18 +03:00
parent 22576c0c40
commit eeac56190c

View File

@@ -107,16 +107,20 @@ function initAuth() {
if (isLoginMode) {
const res = await api.login(username, password);
localStorage.setItem('token', res.token);
// Сразу показываем приложение без перезагрузки
currentUser = await api.getMe();
const planBadge = currentUser.plan === 'pro' ? '<span style="color: gold;">[PRO]</span>' : '<span style="color: gray;">[FREE]</span>';
document.getElementById('username-display').innerHTML = `Привет, ${currentUser.username} ${planBadge}`;
showApp();
if (window.lucide) lucide.createIcons();
} else {
await api.register(username, password);
alert('Регистрация успешна! Теперь вы можете войти.');
isLoginMode = true;
title.textContent = 'Вход в систему';
toggleBtn.textContent = 'Нет аккаунта? Зарегистрироваться';
submitBtn.textContent = 'Войти';
return;
showToast('Регистрация успешна! Войдите в систему.', 'success');
}
window.location.reload();
} catch (err) {
alert(err.message);
}