From d5618452fccabaeafcc7ce614ced2d2f8981cb5f Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 1 Dec 2018 01:46:08 +0100 Subject: [PATCH] Avoid supplying login keys in full-details scenario Apparently Steam network is too stupid to find out that despite of our invalid login key, we also include password and 2FA token, which are valid. Therefore in order to save potential login failure due to invalid login key, let's not use it at all if it's not needed. We still save it as we might need to use it in the future. --- ArchiSteamFarm/Bot.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 32146dd37..71cfc5035 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -1591,11 +1591,14 @@ namespace ArchiSteamFarm { string loginKey = null; if (BotConfig.UseLoginKeys) { - loginKey = BotDatabase.LoginKey; + // Login keys are not guaranteed to be valid, we should use them only if we don't have full details available from the user + if (string.IsNullOrEmpty(BotConfig.DecryptedSteamPassword) || !HasMobileAuthenticator) { + loginKey = BotDatabase.LoginKey; - // Decrypt login key if needed - if (!string.IsNullOrEmpty(loginKey) && (loginKey.Length > 19) && (BotConfig.PasswordFormat != ArchiCryptoHelper.ECryptoMethod.PlainText)) { - loginKey = ArchiCryptoHelper.Decrypt(BotConfig.PasswordFormat, loginKey); + // Decrypt login key if needed + if (!string.IsNullOrEmpty(loginKey) && (loginKey.Length > 19) && (BotConfig.PasswordFormat != ArchiCryptoHelper.ECryptoMethod.PlainText)) { + loginKey = ArchiCryptoHelper.Decrypt(BotConfig.PasswordFormat, loginKey); + } } } else { // If we're not using login keys, ensure we don't have any saved @@ -1620,7 +1623,7 @@ namespace ArchiSteamFarm { ArchiLogger.LogGenericInfo(Strings.BotLoggingIn); if (string.IsNullOrEmpty(TwoFactorCode) && HasMobileAuthenticator) { - // In this case, we can also use ASF 2FA for providing 2FA token, even if it's not required + // We should always include 2FA token, even if it's not required TwoFactorCode = await BotDatabase.MobileAuthenticator.GenerateToken().ConfigureAwait(false); }