SHA256
Restore registration step flow and create new session on login
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { renderHeader } from '../components/header.js?v=20260327192619';
|
||||
import { state } from '../state.js?v=20260327192619';
|
||||
import { authService, state } from '../state.js?v=20260327192619';
|
||||
|
||||
export const pageMeta = { id: 'register-view', title: 'Зарегистрироваться', showAppChrome: false };
|
||||
|
||||
@@ -22,16 +22,41 @@ export function render({ navigate }) {
|
||||
passwordInput.value = state.registrationDraft.password;
|
||||
passwordInput.placeholder = 'Введите пароль';
|
||||
|
||||
const advanced = document.createElement('label');
|
||||
advanced.className = 'checkbox-row';
|
||||
advanced.innerHTML = `<input type="checkbox" /> <span>Расширенные настройки</span>`;
|
||||
const advancedInput = advanced.querySelector('input');
|
||||
advancedInput.addEventListener('change', () => {
|
||||
if (advancedInput.checked) {
|
||||
window.alert('Расширенные настройки в стартовой версии не работают и не будут работать.');
|
||||
advancedInput.checked = false;
|
||||
const statusText = document.createElement('p');
|
||||
statusText.className = 'meta-muted';
|
||||
statusText.textContent = 'Проверка логина: не выполнена';
|
||||
|
||||
const checkButton = document.createElement('button');
|
||||
checkButton.className = 'ghost-btn';
|
||||
checkButton.type = 'button';
|
||||
checkButton.textContent = 'Проверить логин';
|
||||
|
||||
async function runAvailabilityCheck() {
|
||||
const login = loginInput.value.trim();
|
||||
if (!login) {
|
||||
statusText.textContent = 'Введите логин';
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
checkButton.disabled = true;
|
||||
checkButton.textContent = 'Проверка...';
|
||||
try {
|
||||
await authService.reconnect(state.entrySettings.shineServer);
|
||||
const isFree = await authService.ensureLoginFree(login);
|
||||
statusText.textContent = isFree ? 'Логин свободен ✅' : 'Логин уже занят ❌';
|
||||
statusText.className = isFree ? 'is-available' : 'is-unavailable';
|
||||
return isFree;
|
||||
} catch (error) {
|
||||
statusText.textContent = error.message;
|
||||
statusText.className = 'is-unavailable';
|
||||
return false;
|
||||
} finally {
|
||||
checkButton.disabled = false;
|
||||
checkButton.textContent = 'Проверить логин';
|
||||
}
|
||||
}
|
||||
|
||||
checkButton.addEventListener('click', runAvailabilityCheck);
|
||||
|
||||
form.innerHTML = `
|
||||
<label class="stack"><span class="field-label">Логин</span></label>
|
||||
@@ -39,7 +64,7 @@ export function render({ navigate }) {
|
||||
`;
|
||||
form.children[0].append(loginInput);
|
||||
form.children[1].append(passwordInput);
|
||||
form.append(advanced);
|
||||
form.append(checkButton, statusText);
|
||||
|
||||
const actions = document.createElement('div');
|
||||
actions.className = 'auth-footer-actions';
|
||||
@@ -54,9 +79,21 @@ export function render({ navigate }) {
|
||||
nextButton.className = 'primary-btn';
|
||||
nextButton.type = 'button';
|
||||
nextButton.textContent = 'Далее';
|
||||
nextButton.addEventListener('click', () => {
|
||||
state.registrationDraft.login = loginInput.value;
|
||||
nextButton.addEventListener('click', async () => {
|
||||
const isFree = await runAvailabilityCheck();
|
||||
if (!isFree) {
|
||||
window.alert('Выберите свободный логин');
|
||||
return;
|
||||
}
|
||||
|
||||
state.registrationDraft.login = loginInput.value.trim();
|
||||
state.registrationDraft.password = passwordInput.value;
|
||||
|
||||
if (!state.registrationDraft.password) {
|
||||
window.alert('Введите пароль');
|
||||
return;
|
||||
}
|
||||
|
||||
navigate('registration-payment-view');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user