SHA256
Очистить устаревший черновик регистрации
This commit is contained in:
+51
-27
@@ -29,6 +29,31 @@ const INVALID_SESSION_CODES = new Set([
|
||||
'SESSION_OF_ANOTHER_USER',
|
||||
]);
|
||||
|
||||
function createEmptyRegistrationDraft() {
|
||||
return {
|
||||
uiStep: 1,
|
||||
flowType: '',
|
||||
namespaceFeeLamports: '',
|
||||
namespaceServerLogin: '',
|
||||
email: '',
|
||||
challengeId: '',
|
||||
challengeExpiresAtMs: 0,
|
||||
dataItemId: '',
|
||||
login: '',
|
||||
password: '',
|
||||
passwordMode: 'single',
|
||||
passwordWords: emptyPasswordWords(),
|
||||
passwordWordsLinked: false,
|
||||
usePromoCode: false,
|
||||
promoCode: '',
|
||||
sessionId: '',
|
||||
storagePwd: '',
|
||||
pendingKeyBundle: null,
|
||||
pendingSessionMaterial: null,
|
||||
preGeneratedKeyBundle: null,
|
||||
};
|
||||
}
|
||||
|
||||
function isLocalPreviewHost() {
|
||||
const host = String(window.location.hostname || '').toLowerCase();
|
||||
return host === 'localhost' || host === '127.0.0.1' || host === '::1';
|
||||
@@ -458,28 +483,7 @@ function createInitialState({ withStoredSession = true } = {}) {
|
||||
tools: normalizeToolsSettings(storedEntrySettings?.tools),
|
||||
},
|
||||
registrationSuccess: null,
|
||||
registrationDraft: {
|
||||
uiStep: 1,
|
||||
flowType: '',
|
||||
namespaceFeeLamports: '',
|
||||
namespaceServerLogin: '',
|
||||
email: '',
|
||||
challengeId: '',
|
||||
challengeExpiresAtMs: 0,
|
||||
dataItemId: '',
|
||||
login: '',
|
||||
password: '',
|
||||
passwordMode: 'single',
|
||||
passwordWords: emptyPasswordWords(),
|
||||
passwordWordsLinked: false,
|
||||
usePromoCode: false,
|
||||
promoCode: '',
|
||||
sessionId: '',
|
||||
storagePwd: '',
|
||||
pendingKeyBundle: null,
|
||||
pendingSessionMaterial: null,
|
||||
preGeneratedKeyBundle: null,
|
||||
},
|
||||
registrationDraft: createEmptyRegistrationDraft(),
|
||||
registrationHelp: {
|
||||
selectedTopic: 'keys-storage',
|
||||
},
|
||||
@@ -1200,11 +1204,31 @@ export async function refreshSessions() {
|
||||
}
|
||||
|
||||
export function resetRegistrationFlow() {
|
||||
const next = createInitialState();
|
||||
state.registrationDraft = next.registrationDraft;
|
||||
state.registrationSuccess = next.registrationSuccess;
|
||||
state.registrationHelp = next.registrationHelp;
|
||||
state.registrationPayment = next.registrationPayment;
|
||||
clearRegistrationDraft();
|
||||
state.registrationSuccess = null;
|
||||
state.registrationHelp = { selectedTopic: 'keys-storage' };
|
||||
}
|
||||
|
||||
/**
|
||||
* Очищает временные данные регистрации, не затрагивая сохранённые профили и
|
||||
* ключи уже авторизованных пользователей. При смене логина/пароля старые
|
||||
* challenge, dataItemId и производные ключи больше не должны переиспользоваться.
|
||||
*/
|
||||
export function clearRegistrationDraft({
|
||||
preserveFlowType = false,
|
||||
preserveLogin = false,
|
||||
preserveNamespace = false,
|
||||
} = {}) {
|
||||
const draft = state.registrationDraft;
|
||||
const preserved = {
|
||||
flowType: preserveFlowType ? draft.flowType : '',
|
||||
login: preserveLogin ? draft.login : '',
|
||||
namespaceFeeLamports: preserveNamespace ? draft.namespaceFeeLamports : '',
|
||||
namespaceServerLogin: preserveNamespace ? draft.namespaceServerLogin : '',
|
||||
};
|
||||
Object.assign(draft, createEmptyRegistrationDraft(), preserved);
|
||||
state.registrationPayment.walletAddress = '';
|
||||
state.registrationPayment.balanceSOL = '0.0000';
|
||||
}
|
||||
|
||||
function resetStateForSignedOut() {
|
||||
|
||||
Reference in New Issue
Block a user