10
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user