1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-01-19 13:04:43 +08:00

Invalidate account.secretes on failure to lo in

This commit is contained in:
Him188 2022-05-02 10:12:34 +01:00
parent ed37609731
commit 2a417445a7

View File

@ -119,6 +119,7 @@ internal class SsoProcessorImpl(
@Throws(LoginFailedException::class)
override suspend fun login(handler: NetworkHandler) = withExceptionCollector {
components[BdhSessionSyncer].loadServerListFromCache()
try {
if (client.wLoginSigInfoInitialized) {
ssoContext.bot.components[EcdhInitialPublicKeyUpdater].refreshInitialPublicKeyAndApplyECDH()
kotlin.runCatching {
@ -132,6 +133,11 @@ internal class SsoProcessorImpl(
ssoContext.bot.components[EcdhInitialPublicKeyUpdater].refreshInitialPublicKeyAndApplyECDH()
SlowLoginImpl(handler).doLogin()
}
} catch (e: Exception) {
// Failed to log in, invalidate secrets.
ssoContext.bot.components[AccountSecretsManager].invalidate()
throw e
}
components[AccountSecretsManager].saveSecrets(ssoContext.account, AccountSecretsImpl(client))
registerClientOnline(handler)
ssoContext.bot.logger.info { "Login successful." }