Очистить устаревший черновик регистрации

This commit is contained in:
AidarKC
2026-11-16 10:59:27 +03:00
parent 1b86bca19a
commit 102feccb2e
7 changed files with 71 additions and 72 deletions
+2 -8
View File
@@ -5,6 +5,7 @@ import {
authService,
authorizeSession,
clearAuthMessages,
resetRegistrationFlow,
consumeAuthReturnPage,
refreshSessions,
setAuthBusy,
@@ -157,14 +158,7 @@ export function render({ navigate }) {
state.loginDraft.password = '';
state.loginDraft.passwordMode = 'single';
state.loginDraft.passwordWords = emptyPasswordWords();
state.registrationDraft.flowType = '';
state.registrationDraft.password = '';
state.registrationDraft.passwordMode = 'single';
state.registrationDraft.passwordWords = emptyPasswordWords();
state.registrationDraft.storagePwd = '';
state.registrationDraft.sessionId = '';
state.registrationDraft.pendingKeyBundle = null;
state.registrationDraft.pendingSessionMaterial = null;
resetRegistrationFlow();
await refreshSessions();
setAuthInfo(t('screens.login_password_view.text_010', { value1: result.login }));
+7 -10
View File
@@ -3,7 +3,7 @@ import { createTopBar } from '../components/topbar.js';
import { createVisiblePasswordField } from '../components/visible-password-field.js';
import { confirmPasswordBoundarySpaces } from '../services/password-boundary-warning.js';
import { createRegistrationStepper } from '../components/registration-stepper.js';
import { authService, clearAuthMessages, state } from '../state.js';
import { authService, clearAuthMessages, clearRegistrationDraft, state } from '../state.js';
import { PASSWORD_MAX_LENGTH } from '../services/password-words.js';
import { getRegistrationNamespaces, checkRegistrationLogin } from '../services/registration-v2-api.js';
import { normalizeFullLogin } from '../services/shine-namespace-service.js';
@@ -118,11 +118,7 @@ export function render({ navigate }) {
if (Number(available.currencyCode ?? 1) !== 1 || Number(ns.currencyCode ?? 1) !== 1) throw new Error(t('screens.register_view.text_025'));
if (draft.login !== login) {
if (!confirmFundedWalletChange()) return;
state.registrationPayment.walletAddress = '';
state.registrationPayment.balanceSOL = '0.0000';
draft.preGeneratedKeyBundle = null;
draft.challengeId = '';
draft.challengeExpiresAtMs = 0;
clearRegistrationDraft({ preserveFlowType: true });
}
draft.login = login;
draft.namespaceFeeLamports = String(available.registrationFeeLamports ?? ns.registrationFeeLamports ?? 0);
@@ -184,10 +180,11 @@ export function render({ navigate }) {
if (warningRevision !== inputRevision || input.value !== value) { status.textContent = t('screens.register_view.text_012'); return; }
if (draft.password && draft.password !== value && !confirmFundedWalletChange()) return;
if (draft.password && draft.password !== value) {
state.registrationPayment.walletAddress = '';
state.registrationPayment.balanceSOL = '0.0000';
draft.challengeId = '';
draft.challengeExpiresAtMs = 0;
clearRegistrationDraft({
preserveFlowType: true,
preserveLogin: true,
preserveNamespace: true,
});
}
const revision = inputRevision;
const thisRequest = ++requestId;
+4 -10
View File
@@ -1,10 +1,13 @@
import { t } from '../i18n/index.js';
import { createTopBar } from '../components/topbar.js';
import { state } from '../state.js';
import { resetRegistrationFlow, state } from '../state.js';
export const pageMeta = { id: 'registration-choice-view', get title() { return t('screens.registration_choice_view.text_001'); }, showAppChrome: false };
export function render({ navigate }) {
// Экран выбора начинает новую регистрацию. Старый незавершённый черновик
// нельзя переносить в новый сценарий, особенно после неудачной попытки.
resetRegistrationFlow();
const screen = document.createElement('section');
screen.className = 'stack registration-screen signup-choice';
const title = document.createElement('h1');
@@ -45,15 +48,6 @@ export function render({ navigate }) {
action.textContent = button;
action.addEventListener('click', () => {
const draft = state.registrationDraft;
if (draft.flowType !== type) {
// При смене namespace старые ключи/коды больше не соответствуют выбранному аккаунту.
draft.login = '';
draft.password = '';
draft.preGeneratedKeyBundle = null;
draft.challengeId = '';
draft.challengeExpiresAtMs = 0;
draft.email = '';
}
draft.flowType = type;
draft.uiStep = 1;
navigate('register-view');
+3 -16
View File
@@ -140,22 +140,9 @@ export async function completeRegistrationLogin({ navigate, keyBundle }) {
state.loginDraft.passwordMode = 'single';
state.loginDraft.passwordWords = EMPTY_PASSWORD_WORDS.slice();
state.registrationSuccess = { flowType: state.registrationDraft.flowType, login: resumedLogin };
state.registrationDraft.flowType = '';
state.registrationDraft.password = '';
state.registrationDraft.passwordMode = 'single';
state.registrationDraft.passwordWords = EMPTY_PASSWORD_WORDS.slice();
state.registrationDraft.passwordWordsLinked = false;
state.registrationDraft.usePromoCode = false;
state.registrationDraft.promoCode = '';
state.registrationDraft.storagePwd = '';
state.registrationDraft.sessionId = '';
state.registrationDraft.pendingKeyBundle = null;
state.registrationDraft.pendingSessionMaterial = null;
state.registrationDraft.preGeneratedKeyBundle = null;
state.registrationPayment.walletAddress = '';
state.registrationPayment.balanceSOL = '0.0000';
const completedFlowType = state.registrationDraft.flowType;
resetRegistrationFlow();
state.registrationSuccess = { flowType: completedFlowType, login: resumedLogin };
try {
await refreshSessions();