feat(auth): вход по токену с обязательным ручным спуфом устройства

This commit is contained in:
klockky
2026-06-21 09:23:34 +00:00
parent d96499d88d
commit f20a818825
8 changed files with 453 additions and 0 deletions
+19
View File
@@ -1060,6 +1060,25 @@ class AccountModule {
logger.i('Добавление аккаунта: сессия сброшена, активный аккаунт очищен');
}
Future<LoginResult> loginWithToken(String token) async {
await TokenStorage.clearActiveAccount();
try {
await _api.disconnect();
} catch (_) {}
ContactCache.clear();
TranscriptionCache.clear();
ChatsModule.resetForAccountSwitch();
await _api.connect();
if (_api.state != SessionState.online) {
throw StateError('loginWithToken: нет соединения с сервером');
}
logger.i('Вход по токену: сессия поднята со спуфом, выполняю login');
return login(token: token);
}
Future<ProfileData> switchAccount(int accountId) async {
final profile = await AppDatabase.loadProfile(accountId);
if (profile == null) {