Fix SteamPassword input

Asking for password with encryption enabled always resulted in an error, as the password wasn't properly set to the plaintext and we were back to square one.

The previous logic was overly complex, I don't know why, this should achieve the same and be much easier to understand while at it.
This commit is contained in:
Archi 2022-04-29 17:55:33 +02:00
parent a826b7f9b7
commit 1dcf98c849
No known key found for this signature in database
GPG key ID: 6B138B4C64555AEA
3 changed files with 16 additions and 13 deletions

View file

@ -123,7 +123,10 @@ public sealed class BotController : ArchiController {
}
if (!request.BotConfig.IsSteamPasswordSet && bot.BotConfig.IsSteamPasswordSet) {
request.BotConfig.SetDecryptedSteamPassword(await bot.BotConfig.GetDecryptedSteamPassword().ConfigureAwait(false));
request.BotConfig.SteamPassword = bot.BotConfig.SteamPassword;
// Since we're inheriting the password, we should also inherit the format, whatever that might be
request.BotConfig.PasswordFormat = bot.BotConfig.PasswordFormat;
}
if (!request.BotConfig.IsSteamParentalCodeSet && bot.BotConfig.IsSteamParentalCodeSet) {

View file

@ -860,13 +860,20 @@ public sealed class Bot : IAsyncDisposable {
switch (inputType) {
case ASF.EUserInputType.Login:
BotConfig.SteamLogin = inputValue;
// Do not allow saving this account credential
BotConfig.IsSteamLoginSet = false;
break;
case ASF.EUserInputType.Password:
BotConfig.SetDecryptedSteamPassword(inputValue);
BotConfig.SteamPassword = inputValue;
// Do not allow saving this account credential
BotConfig.IsSteamPasswordSet = false;
// If by any chance user has wrongly configured password format, we reset it back to plaintext
BotConfig.PasswordFormat = ArchiCryptoHelper.ECryptoMethod.PlainText;
break;
case ASF.EUserInputType.SteamGuard:
if (inputValue.Length != 5) {
@ -882,6 +889,8 @@ public sealed class Bot : IAsyncDisposable {
}
BotConfig.SteamParentalCode = inputValue;
// Do not allow saving this account credential
BotConfig.IsSteamParentalCodeSet = false;
break;

View file

@ -196,7 +196,7 @@ public sealed class BotConfig {
public EPersonaState OnlineStatus { get; private set; } = DefaultOnlineStatus;
[JsonProperty(Required = Required.DisallowNull)]
public ArchiCryptoHelper.ECryptoMethod PasswordFormat { get; private set; } = DefaultPasswordFormat;
public ArchiCryptoHelper.ECryptoMethod PasswordFormat { get; internal set; } = DefaultPasswordFormat;
[JsonProperty(Required = Required.DisallowNull)]
public bool Paused { get; private set; } = DefaultPaused;
@ -524,7 +524,7 @@ public sealed class BotConfig {
return null;
}
if (PasswordFormat == ArchiCryptoHelper.ECryptoMethod.PlainText) {
if (!PasswordFormat.HasTransformation()) {
return SteamPassword;
}
@ -631,15 +631,6 @@ public sealed class BotConfig {
return (botConfig, json != latestJson ? latestJson : null);
}
internal void SetDecryptedSteamPassword(string? decryptedSteamPassword) {
if (!string.IsNullOrEmpty(decryptedSteamPassword) && PasswordFormat.HasTransformation()) {
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
decryptedSteamPassword = ArchiCryptoHelper.Encrypt(PasswordFormat, decryptedSteamPassword!);
}
SteamPassword = decryptedSteamPassword;
}
public enum EAccess : byte {
None,
FamilySharing,