Добавить смену профилей, пока не работает

This commit is contained in:
AidarKC
2026-09-03 12:51:46 +04:00
parent ebc9143593
commit e0295eebde
8 changed files with 227 additions and 43 deletions
+16 -8
View File
@@ -1,6 +1,8 @@
import {
authService,
authorizeSession,
consumeAuthReturnPage,
isAddingProfileLogin,
clearAuthMessages,
clearBrowserClientData,
refreshSessions,
@@ -182,10 +184,13 @@ export function render({ navigate }) {
const finalizeAuthorizedLogin = async (keys, login) => {
const session = await authService.createSessionFromImportedSecrets(login, keys);
await terminateCurrentSession({ closeServerSession: true, notifySessionReset: false });
const addingProfile = isAddingProfileLogin();
if (!addingProfile) {
await terminateCurrentSession({ closeServerSession: true, notifySessionReset: false });
clearBrowserClientData();
await clearClientAuthData().catch(() => {});
}
await clearStoredMessages(session.login).catch(() => {});
clearBrowserClientData();
await clearClientAuthData().catch(() => {});
await saveEncryptedUserSecrets(session.login, session.storagePwd, keys);
await authService.persistSessionMaterial(session.login, session.sessionMaterial);
const resumed = await authService.resumeSession(session.login, session.sessionId);
@@ -199,7 +204,7 @@ export function render({ navigate }) {
await refreshSessions();
setAuthInfo(`Вход через другое устройство выполнен для @${resumed.login || session.login}.`);
showToast(`Устройство подключено для @${resumed.login || session.login}`);
navigate('profile-view');
navigate(consumeAuthReturnPage('profile-view'));
};
const finalizeAuthorizedSessionAttach = async (payloadSession, login, requesterKeys) => {
@@ -215,10 +220,13 @@ export function render({ navigate }) {
sessionType: Number(payloadSession?.sessionType || 50) || 50,
};
await terminateCurrentSession({ closeServerSession: true, notifySessionReset: false });
const addingProfile = isAddingProfileLogin();
if (!addingProfile) {
await terminateCurrentSession({ closeServerSession: true, notifySessionReset: false });
clearBrowserClientData();
await clearClientAuthData().catch(() => {});
}
await clearStoredMessages(login).catch(() => {});
clearBrowserClientData();
await clearClientAuthData().catch(() => {});
await authService.persistSessionMaterial(login, sessionMaterial);
const resumed = await authService.resumeSession(login, sessionId);
authorizeSession({
@@ -231,7 +239,7 @@ export function render({ navigate }) {
await refreshSessions();
setAuthInfo(`Session-only вход выполнен для @${resumed.login || login}.`);
showToast(`Wallet-session подключена для @${resumed.login || login}`);
navigate('profile-view');
navigate(consumeAuthReturnPage('profile-view'));
};
const schedulePoll = () => {