From f042c9d14ee308b8c7fff574b7ef319ce51dbd22 Mon Sep 17 00:00:00 2001 From: alina sireneva Date: Thu, 30 Jan 2025 14:47:20 +0300 Subject: [PATCH] fix(core): drop non-primary auth keys on logout --- packages/core/src/highlevel/base.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/core/src/highlevel/base.ts b/packages/core/src/highlevel/base.ts index 71c2cac6..2d01f7e3 100644 --- a/packages/core/src/highlevel/base.ts +++ b/packages/core/src/highlevel/base.ts @@ -177,6 +177,13 @@ export class BaseTelegramClient implements ITelegramClient { this.log.prefix = '[USER n/a] ' await this.storage.self.store(null) + + // drop non-primary auth keys because they are no longer valid + const primaryDc = this.mt.network.getPrimaryDcId() + for (const dc of this.mt.network.config.getCached()?.dcOptions ?? []) { + if (dc.id === primaryDc) continue + await this.mt.storage.provider.authKeys.deleteByDc(dc.id) + } } async notifyChannelOpened(channelId: number, pts?: number): Promise {