提交 540dfbc2 编写于 作者: J john.jiang

🎨 令牌插件代码多余空格取出,WinAuth子模块更新

上级 5d35de8f
Subproject commit 19d3414133184c1981a3094aa7360b6cc624b3ee
Subproject commit b2ee8199c6a3488c31077dae86c72a9c8e8d0dab
......@@ -9,8 +9,8 @@ public interface IAuthenticatorImport
public ResIcon IconName { get; }
public ICommand AuthenticatorImportCommand { get; set; }
Task<bool> VerifyMaxValue();
Task SaveAuthenticator(IAuthenticatorDTO authenticatorDto);
}
\ No newline at end of file
......@@ -5,5 +5,5 @@ namespace BD.WTTS.Models;
[JsonSerializable(typeof(SdaFileConvertToSteamDataModel))]
public partial class ImportFileModelJsonContext : JsonSerializerContext
{
}
......@@ -7,37 +7,37 @@ public class SdaFileModel
[JsonPropertyName("serial_number")]
public string SerialNumber { get; set; } = string.Empty;
[JsonPropertyName("revocation_code")]
public string RevocationCode { get; set; } = string.Empty;
[JsonPropertyName("uri")]
public string Uri { get; set; } = string.Empty;
[JsonPropertyName("server_time")]
public string ServerTime { get; set; } = string.Empty;
[JsonPropertyName("account_name")]
public string AccountName { get; set; } = string.Empty;
[JsonPropertyName("token_gid")]
public string TokenGid { get; set; } = string.Empty;
[JsonPropertyName("identity_secret")]
public string IdentitySecret { get; set; } = string.Empty;
[JsonPropertyName("secret_1")]
public string Secret1 { get; set; } = string.Empty;
[JsonPropertyName("status")]
public int Status { get; set; }
[JsonPropertyName("device_id")]
public string DeviceId { get; set; } = string.Empty;
[JsonPropertyName("fully_enrolled")]
public bool FullyEnrolled { get; set; }
[JsonPropertyName("Session")]
public Session? Session { get; set; }
}
......@@ -49,28 +49,28 @@ public class SdaFileConvertToSteamDataModel
[JsonPropertyName("serial_number")]
public string SerialNumber { get; set; } = string.Empty;
[JsonPropertyName("revocation_code")]
public string RevocationCode { get; set; } = string.Empty;
[JsonPropertyName("uri")]
public string Uri { get; set; } = string.Empty;
[JsonPropertyName("server_time")]
public string ServerTime { get; set; } = string.Empty;
[JsonPropertyName("account_name")]
public string AccountName { get; set; } = string.Empty;
[JsonPropertyName("token_gid")]
public string TokenGid { get; set; } = string.Empty;
[JsonPropertyName("identity_secret")]
public string IdentitySecret { get; set; } = string.Empty;
[JsonPropertyName("secret_1")]
public string Secret1 { get; set; } = string.Empty;
[JsonPropertyName("status")]
public int Status { get; set; }
......@@ -93,19 +93,19 @@ public class Session
{
[JsonPropertyName("SessionID")]
public string SessionId { get; set; } = string.Empty;
[JsonPropertyName("SteamLogin")]
public string SteamLogin { get; set; } = string.Empty;
[JsonPropertyName("SteamLoginSecure")]
public string SteamLoginSecure { get; set; } = string.Empty;
[JsonPropertyName("WebCookie")]
public string WebCookie { get; set; } = string.Empty;
[JsonPropertyName("OAuthToken")]
public string OAuthToken { get; set; } = string.Empty;
[JsonPropertyName("SteamID")]
public long SteamId { get; set; }
}
......
......@@ -2,7 +2,7 @@ namespace BD.WTTS.Models;
public class SteamGuardModel
{
[JsonPropertyName("shared_secret")]
[JsonPropertyName("shared_secret")]
public string SharedSecret { get; set; } = string.Empty;
[JsonPropertyName("serial_number")]
......
......@@ -5,11 +5,11 @@ namespace BD.WTTS.Models;
public abstract class AuthenticatorFileImportBase : AuthenticatorImportBase
{
public abstract override string Name { get; }
public abstract override string Description { get; }
protected abstract string? FileExtension { get; }
public abstract override ICommand AuthenticatorImportCommand { get; set; }
protected async Task<string?> SelectFolderPath()
......@@ -28,11 +28,11 @@ public abstract class AuthenticatorFileImportBase : AuthenticatorImportBase
options.FileTypes = fileTypes;
return await FilePicker2.PickAsync(options);
}
protected bool ReadXml(ref AuthenticatorDTO authenticatorDto, XmlReader reader, string? password)
{
bool changed = false;
var authenticatorType = reader.GetAttribute("type");
switch (authenticatorType)
{
......@@ -121,7 +121,7 @@ public abstract class AuthenticatorFileImportBase : AuthenticatorImportBase
return changed;
}
protected IEnumerable<string> ReadUrlsByFilePath(string filePath)
{
StringBuilder lines = new();
......
......@@ -3,11 +3,11 @@ namespace BD.WTTS.Models;
public abstract class AuthenticatorGeneralImportBase : AuthenticatorImportBase
{
public abstract override string Name { get; }
public abstract override string Description { get; }
public abstract override ResIcon IconName { get; }
public abstract override ICommand AuthenticatorImportCommand { get; set; }
protected abstract Task<IAuthenticatorValueDTO?> CreateAuthenticatorValueDto(string secretCode);
......
......@@ -10,9 +10,9 @@ public class AuthenticatorGoogleGeneralImport : AuthenticatorGeneralImportBase
public override string Description => Strings.LocalAuth_GoogleImport;
public override ResIcon IconName => ResIcon.Attach;
public sealed override ICommand AuthenticatorImportCommand { get; set; }
public AuthenticatorGoogleGeneralImport()
{
AuthenticatorImportCommand = ReactiveCommand.Create(async () =>
......@@ -24,7 +24,7 @@ public class AuthenticatorGoogleGeneralImport : AuthenticatorGeneralImportBase
pageContent: new AuthenticatorGeneralImportPage(), isOkButton: false);
});
}
protected override async Task<IAuthenticatorValueDTO?> CreateAuthenticatorValueDto(string secretCode)
{
try
......@@ -36,7 +36,7 @@ public class AuthenticatorGoogleGeneralImport : AuthenticatorGeneralImportBase
Toast.Show(ToastIcon.Error, Strings.LocalAuth_Import_DecodePrivateKeyError.Format("Google"));
return null;
}
var auth = new GoogleAuthenticator();
auth.Enroll(privateKey);
......
......@@ -10,7 +10,7 @@ public class AuthenticatorHOTPGeneralImport : AuthenticatorGeneralImportBase
public override string Description => Strings.LocalAuth_HOTPImport;
public override ResIcon IconName => ResIcon.Attach;
public sealed override ICommand AuthenticatorImportCommand { get; set; }
public AuthenticatorHOTPGeneralImport()
......@@ -24,7 +24,7 @@ public class AuthenticatorHOTPGeneralImport : AuthenticatorGeneralImportBase
pageContent: new AuthenticatorGeneralImportPage(), isOkButton: false);
});
}
protected override async Task<IAuthenticatorValueDTO?> CreateAuthenticatorValueDto(string secretCode)
{
try
......@@ -36,7 +36,7 @@ public class AuthenticatorHOTPGeneralImport : AuthenticatorGeneralImportBase
Toast.Show(ToastIcon.Error, Strings.LocalAuth_Import_DecodePrivateKeyError.Format("HOTP"));
return null;
}
var auth = new HOTPAuthenticator();
auth.Enroll(privateKey);
return auth;
......
......@@ -3,13 +3,13 @@ namespace BD.WTTS.Models;
public abstract partial class AuthenticatorImportBase : IAuthenticatorImport
{
public abstract string Name { get; }
public abstract string Description { get; }
public abstract ResIcon IconName { get; }
public abstract ICommand AuthenticatorImportCommand { get; set; }
string? _currentPassword { get; set; }
public async Task<bool> VerifyMaxValue()
......@@ -22,8 +22,8 @@ public abstract partial class AuthenticatorImportBase : IAuthenticatorImport
public async Task SaveAuthenticator(IAuthenticatorDTO authenticatorDto)
{
var sourceList = await AuthenticatorService.GetAllSourceAuthenticatorAsync();
var sourceList = await AuthenticatorService.GetAllSourceAuthenticatorAsync();
var (hasLocalPcEncrypt, hasPasswordEncrypt) = AuthenticatorService.HasEncrypt(sourceList);
if (hasPasswordEncrypt && string.IsNullOrEmpty(_currentPassword))
......
......@@ -17,7 +17,7 @@ public partial class AuthenticatorItemModel : ItemViewModel
readonly DispatcherTimer _progressTimer;
int _progress;
public void OnPointerLeftPressed()
{
IsSelected = !IsSelected;
......@@ -32,7 +32,7 @@ public partial class AuthenticatorItemModel : ItemViewModel
{
await CopyCode();
}
async Task CopyCode()
{
if (!IsShowCode) return;
......@@ -49,7 +49,7 @@ public partial class AuthenticatorItemModel : ItemViewModel
_progressTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) };
_progressTimer.Tick += ShowCode;
}
async void ShowCode(object? sender, EventArgs e)
{
_progress -= 1;
......
......@@ -49,7 +49,7 @@ public partial class AuthenticatorItemModel
get => _strokeColor;
set => this.RaiseAndSetIfChanged(ref _strokeColor, value);
}
public double Value
{
get => _value;
......
......@@ -10,7 +10,7 @@ public class AuthenticatorMicrosoftGeneralImport : AuthenticatorGeneralImportBas
public override string Description => Strings.LocalAuth_MicrosoftImport;
public override ResIcon IconName => ResIcon.Attach;
public sealed override ICommand AuthenticatorImportCommand { get; set; }
public AuthenticatorMicrosoftGeneralImport()
......@@ -24,7 +24,7 @@ public class AuthenticatorMicrosoftGeneralImport : AuthenticatorGeneralImportBas
pageContent: new AuthenticatorGeneralImportPage(), isOkButton: false);
});
}
protected override async Task<IAuthenticatorValueDTO?> CreateAuthenticatorValueDto(string secretCode)
{
try
......@@ -36,7 +36,7 @@ public class AuthenticatorMicrosoftGeneralImport : AuthenticatorGeneralImportBas
Toast.Show(ToastIcon.Error, Strings.LocalAuth_Import_DecodePrivateKeyError.Format("Microsoft"));
return null;
}
var auth = new MicrosoftAuthenticator();
auth.Enroll(privateKey);
......
......@@ -2,7 +2,7 @@ namespace BD.WTTS.Models;
public class AuthenticatorRecoverModel
{
[Reactive]
[Reactive]
public UserAuthenticatorDeleteBackupResponse AuthenticatorDeleteBackup { get; set; }
[Reactive]
......
......@@ -22,17 +22,17 @@ public class AuthenticatorSdaFileImport : AuthenticatorFileImportBase
await ImportFromSdaFile(password);
});
}
async Task ImportFromSdaFile(string? password = null)
{
try
{
var filePath = await SelectFolderPath();
if (string.IsNullOrEmpty(filePath)) return;
var text = await File.ReadAllTextAsync(filePath);
var index = text.IndexOf("\"server_time\":", StringComparison.Ordinal) + 14;
if (index != -1)
{
......@@ -47,7 +47,7 @@ public class AuthenticatorSdaFileImport : AuthenticatorFileImportBase
var sdaFileModel = JsonSerializer.Deserialize(text, ImportFileModelJsonContext.Default.SdaFileModel);
sdaFileModel.ThrowIsNull();
var steamDataModel = new SdaFileConvertToSteamDataModel(sdaFileModel);
SteamAuthenticator steamAuthenticator = new()
{
DeviceId = sdaFileModel.DeviceId,
......@@ -55,11 +55,13 @@ public class AuthenticatorSdaFileImport : AuthenticatorFileImportBase
SecretKey = Convert.FromBase64String(sdaFileModel.SharedSecret),
SteamData = JsonSerializer.Serialize(steamDataModel, ImportFileModelJsonContext.Default.SdaFileConvertToSteamDataModel),
};
var authDto =
new AuthenticatorDTO()
{
Name = $"(Steam){steamAuthenticator.AccountName}", Value = steamAuthenticator, Created = DateTimeOffset.Now,
Name = $"(Steam){steamAuthenticator.AccountName}",
Value = steamAuthenticator,
Created = DateTimeOffset.Now,
};
await SaveAuthenticator(authDto);
Toast.Show(ToastIcon.Success, Strings.ModelContent_ImportSuccessful_.Format(authDto.Name));
......
......@@ -9,7 +9,7 @@ public class AuthenticatorSteamLoginImport : AuthenticatorImportBase
public override string Description => Strings.Steam_UserLoginTip;
public override ResIcon IconName => ResIcon.Contact;
public sealed override ICommand AuthenticatorImportCommand { get; set; }
public AuthenticatorSteamLoginImport()
......
......@@ -20,11 +20,11 @@ public class AuthenticatorWattToolKitV1Import : AuthenticatorFileImportBase
await ImportFromWattToolKitV1(password);
});
}
async Task ImportFromWattToolKitV1(string? password = null)
{
var filePath = await SelectFolderPath();
if (string.IsNullOrEmpty(filePath)) return;
if (IOPath.TryReadAllText(filePath, out var content, out var _))
......
......@@ -5,7 +5,7 @@ public class AuthenticatorWattToolKitV2Import : AuthenticatorFileImportBase
public override string Name => Strings.LocalAuth_Import.Format(Strings.WattToolKitV2);
public override string Description => Strings.LocalAuth_WattToolKitV2Import;
public override ResIcon IconName => ResIcon.OpenFile;
public sealed override ICommand AuthenticatorImportCommand { get; set; }
......@@ -20,13 +20,13 @@ public class AuthenticatorWattToolKitV2Import : AuthenticatorFileImportBase
await ImportFromWattToolKitV2(password: password);
});
}
async Task ImportFromWattToolKitV2(string? exportPassword = null, string? password = null)
{
var filePath = await SelectFolderPath();
if (string.IsNullOrEmpty(filePath)) return;
var metadata = await IOPath.TryReadAllBytesAsync(filePath);
if (!metadata.success || metadata.byteArray == null) return;
var result = await AuthenticatorService.ImportAsync(exportPassword, metadata.byteArray);
......
......@@ -7,7 +7,7 @@ public class AuthenticatorWinAuthFileImport : AuthenticatorFileImportBase
public override string Name => Strings.LocalAuth_Import.Format(Strings.WinAuth);
public override string Description => Strings.LocalAuth_WinAuthImport;
public override ResIcon IconName => ResIcon.OpenFile;
public sealed override ICommand AuthenticatorImportCommand { get; set; }
......@@ -22,7 +22,7 @@ public class AuthenticatorWinAuthFileImport : AuthenticatorFileImportBase
await ImportFromWinAuthFile(password);
});
}
async Task ImportFromWinAuthFile(string? password = null)
{
var filePath = await SelectFolderPath();
......@@ -99,7 +99,7 @@ public class AuthenticatorWinAuthFileImport : AuthenticatorFileImportBase
}
AuthenticatorDTO authenticatorDto = new();
AuthenticatorValueDTO auth;
if (string.Compare(issuer, "BattleNet", StringComparison.OrdinalIgnoreCase) == 0)
{
......@@ -177,7 +177,7 @@ public class AuthenticatorWinAuthFileImport : AuthenticatorFileImportBase
{
auth.HMACType = hmactype;
}
if (label.Length != 0)
{
authenticatorDto.Name = issuer.Length != 0 ? issuer + " (" + label + ")" : label;
......@@ -190,7 +190,7 @@ public class AuthenticatorWinAuthFileImport : AuthenticatorFileImportBase
{
authenticatorDto.Name = "Imported";
}
authenticatorDto.Value = auth;
// sync
......
......@@ -8,31 +8,31 @@ public class SteamTradeConfirmationModel : ReactiveObject
public int Type { get; set; }
public string TypeName { get; set; } = string.Empty;
public string Id { get; set; } = string.Empty;
public string CreatorId { get; set; } = string.Empty;
public string Nonce { get; set; } = string.Empty;
long CreationTime { get; set; }
public string Cancel { get; set; } = string.Empty;
public string Accept { get; set; } = string.Empty;
public string Icon { get; set; } = string.Empty;
public bool Multi { get; set; }
public string Headline { get; set; } = string.Empty;
string[]? Summary { get; set; }
public string? Warn { get; set; }
public string? SelfIcon { get; set; }
public string SendSummary => Summary![0];
public string ReceiveSummary => Summary![1];
......@@ -45,7 +45,7 @@ public class SteamTradeConfirmationModel : ReactiveObject
[Reactive]
public ObservableCollection<string> SendItemImageUrls { get; set; }
[Reactive]
public ObservableCollection<string> ReceiveItemImageUrls { get; set; }
......@@ -103,14 +103,14 @@ public class SteamTradeConfirmationModel : ReactiveObject
{
ReceiveItemImageUrls.Add(item);
}
SendItemImageUrls.Clear();
foreach (var item in imageUrls.sendItems)
{
SendItemImageUrls.Add(item);
}
}
async Task<T?> RunTaskAndExceptionHandlingAsync<T>(Task<T> task)
{
try
......
......@@ -83,7 +83,7 @@ internal sealed class AccountPlatformAuthenticatorRepository : Repository<Accoun
var resultCode__ = (ImportResultCode)resultCode_;
return resultCode__;
}
public async Task<bool> Exists(IEnumerable<AccountPlatformAuthenticator> sourceList, IAuthenticatorDTO item,
bool isLocal, string? secondaryPassword = null)
{
......
......@@ -178,7 +178,7 @@ public sealed partial class AuthenticatorService
else
{
fileTypes = null;
}
}
exportFile = await FilePicker2.SaveAsync(new PickOptions
{
FileTypes = fileTypes,
......@@ -186,13 +186,13 @@ public sealed partial class AuthenticatorService
PickerTitle = "Watt Toolkit",
});
if (exportFile == null) return exportFile;
var filestream = exportFile.OpenWrite();
if (filestream.CanSeek && filestream.Position != 0) filestream.Position = 0;
await repository.ExportAsync(filestream, isLocal, password, items);
await filestream.FlushAsync();
await filestream.DisposeAsync();
}
......@@ -275,7 +275,7 @@ public sealed partial class AuthenticatorService
Toast.Show(ToastIcon.Warning, AppResources.Error_UpdateCloudData);
return 0;
}
/// <summary>
/// 验证安全问题
/// </summary>
......@@ -301,7 +301,8 @@ public sealed partial class AuthenticatorService
var setPassword =
await IMicroServiceClient.Instance.AuthenticatorClient.SetIndependentPassword(new()
{
PwdQuestion = question, Answer = answer,
PwdQuestion = question,
Answer = answer,
});
if (!setPassword.IsSuccess)
{
......@@ -316,7 +317,7 @@ public sealed partial class AuthenticatorService
AppResources.Title_PleaseEnterTheAnswer, subHeader: AppResources.SubHeader_SecurityIssues_.Format(question), isCancelButton: true))
{
answer = answerTextViewModel.Value;
if (string.IsNullOrEmpty(answer))
{
Toast.Show(ToastIcon.Error, AppResources.Error_PleaseEnterAnswer);
......@@ -411,7 +412,7 @@ public sealed partial class AuthenticatorService
if (response.StatusCode == HttpStatusCode.OK)
{
//response.Content.Headers.ContentType.;
using (var bitmap = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(await response.Content.ReadAsStreamAsync()))
{
//二维码解析
......
......@@ -78,9 +78,9 @@ public class AuthenticatorExportViewModel : ViewModelBase
public AuthenticatorExportViewModel()
{
}
public AuthenticatorExportViewModel(string? password = null)
{
_currentPassword = password;
......
......@@ -5,7 +5,7 @@ public partial class AuthenticatorGeneralImportPageViewModel
readonly Func<IAuthenticatorDTO, Task> _saveAuth;
readonly Func<string, Task<IAuthenticatorValueDTO?>> _createAuthenticatorValueDto;
IAuthenticatorValueDTO? _importAuthenticatorValueDto;
public AuthenticatorGeneralImportPageViewModel()
......@@ -28,9 +28,9 @@ public partial class AuthenticatorGeneralImportPageViewModel
Toast.Show(ToastIcon.Info, Strings.Info_PleaseEnterImportText);
return;
}
_importAuthenticatorValueDto = await _createAuthenticatorValueDto.Invoke(SecretCode);
if (_importAuthenticatorValueDto != null)
CurrentCode = _importAuthenticatorValueDto.CurrentCode;
}
......@@ -48,7 +48,7 @@ public partial class AuthenticatorGeneralImportPageViewModel
Toast.Show(ToastIcon.Warning, Strings.Warning_PleaseEnterAuthName);
return;
}
var iAuthenticatorDtoDto = new AuthenticatorDTO()
{
Name = $"{_importAuthenticatorValueDto.Platform}({AuthenticatorName})",
......
......@@ -4,11 +4,11 @@ public class AuthenticatorImportPageViewModel : ViewModelBase
{
[Reactive]
public ObservableCollection<AuthenticatorImportBase> AuthenticatorImportBases { get; set; }
public AuthenticatorImportPageViewModel()
{
AuthenticatorImportBases = new ObservableCollection<AuthenticatorImportBase>();
Initialize();
}
......
......@@ -13,7 +13,7 @@ public sealed partial class AuthenticatorPageViewModel : ViewModelBase
const int MAX_SYNC_VALUE = 100;
string? _currentAnswer;
string? _currentPassword;
DateTime _initializeTime;
......@@ -256,7 +256,7 @@ public sealed partial class AuthenticatorPageViewModel : ViewModelBase
response.Content.ThrowIsNull();
var cloudAuths = response.Content.Select(AuthenticatorService.ConvertToAuthenticatorDto).ToList();
if (cloudAuths.Count >= Auths.Count)
{
int changes = 0;
......@@ -308,7 +308,8 @@ public sealed partial class AuthenticatorPageViewModel : ViewModelBase
return;
}
var pushItems = (from item in Auths
var pushItems = (
from item in Auths
let cloudAuth = cloudAuths.FirstOrDefault(i => i.ServerId == item.AuthData.ServerId)
where cloudAuth == null
select new UserAuthenticatorPushItem()
......@@ -330,7 +331,8 @@ public sealed partial class AuthenticatorPageViewModel : ViewModelBase
var syncResponse = await IMicroServiceClient.Instance.AuthenticatorClient.SyncAuthenticatorsToCloud(new()
{
Difference = pushItems, Answer = _currentAnswer,
Difference = pushItems,
Answer = _currentAnswer,
});
if (!syncResponse.IsSuccess)
......@@ -391,7 +393,7 @@ public sealed partial class AuthenticatorPageViewModel : ViewModelBase
isCancelButton: true)) return;
var answer = textViewModel.Value;
if (string.IsNullOrEmpty(question) || string.IsNullOrEmpty(answer)) return;
var resetPassword = await IMicroServiceClient.Instance.AuthenticatorClient.ResetIndependentPassword(new ()
var resetPassword = await IMicroServiceClient.Instance.AuthenticatorClient.ResetIndependentPassword(new()
{
Answer = _currentAnswer,
NewPwdQuestion = question,
......@@ -450,7 +452,8 @@ public sealed partial class AuthenticatorPageViewModel : ViewModelBase
var textViewmodel = new TextBoxWindowViewModel
{
InputType = TextBoxWindowViewModel.TextBoxInputType.TextBox, Value = CurrentSelectedAuth.AuthName
InputType = TextBoxWindowViewModel.TextBoxInputType.TextBox,
Value = CurrentSelectedAuth.AuthName
};
if (await IWindowManager.Instance.ShowTaskDialogAsync(textViewmodel, AppResources.Title_PleaseEnterNewAuthName, isDialog: false,
isCancelButton: true))
......@@ -559,15 +562,16 @@ public sealed partial class AuthenticatorPageViewModel : ViewModelBase
await IWindowManager.Instance.ShowTaskDialogAsync(
new TextBoxWindowViewModel()
{
InputType = TextBoxWindowViewModel.TextBoxInputType.TextBox, Value = temp,
InputType = TextBoxWindowViewModel.TextBoxInputType.TextBox,
Value = temp,
}, AppResources.ModelContent_SecretKey_.Format(CurrentSelectedAuth.AuthName), isDialog: false, isOkButton: false);
}
}
public async void ExportAuthWithSdaFile(object sender)
{
if (sender is not AuthenticatorItemModel authenticatorItemModel) return;
if (authenticatorItemModel.AuthData.Value is SteamAuthenticator steamAuthenticator)
{
if (string.IsNullOrEmpty(steamAuthenticator.SteamData)) return;
......@@ -656,7 +660,7 @@ public sealed partial class AuthenticatorPageViewModel : ViewModelBase
}
Auths.Move(index, index - 1);
}
public async Task AuthenticatorIndexMoveDown(object sender)
{
if (sender is not AuthenticatorItemModel authenticatorItemModel) return;
......@@ -707,11 +711,11 @@ public sealed partial class AuthenticatorPageViewModel : ViewModelBase
if (exportFile == null) return;
Toast.Show(ToastIcon.Success, Strings.ExportedToPath_.Format(exportFile.ToString()));
}
public async Task UnbindingSteamAuthAsync(object sender)
{
if (sender is not AuthenticatorItemModel authenticatorItemModel) return;
if (authenticatorItemModel.AuthData.Platform != AuthenticatorPlatform.Steam)
{
Toast.Show(ToastIcon.Warning, AppResources.Warning_OnlySupportSteamAuth);
......
......@@ -41,7 +41,8 @@ public class AuthenticatorRecoverPageViewModel : ViewModelBase
var ids = list.Select(a => a.AuthenticatorDeleteBackup.Id).ToArray();
var response = await IMicroServiceClient.Instance.AuthenticatorClient.RecoverAuthenticatorsFromDeleteBackups(new()
{
Answer = _currentAnswer, Id = ids,
Answer = _currentAnswer,
Id = ids,
});
if (!response.IsSuccess) return;
AuthenticatorDeleteBackups.Remove(list);
......
......@@ -33,7 +33,7 @@ public class AuthenticatorSteamGuardViewModel : ViewModelBase
this.RaisePropertyChanged();
}
}
public string? ImportAuthNewName
{
get => _importAuthNewName;
......@@ -48,7 +48,7 @@ public class AuthenticatorSteamGuardViewModel : ViewModelBase
this.RaisePropertyChanged();
}
}
readonly Func<IAuthenticatorDTO, Task> _saveAuth;
public AuthenticatorSteamGuardViewModel()
......@@ -103,7 +103,7 @@ public class AuthenticatorSteamGuardViewModel : ViewModelBase
RegexOptions.Singleline | RegexOptions.IgnoreCase) == false)
{
//WinAuthForm.ErrorDialog(this, "Invalid deviceid, expecting \"android:NNNN...\"");
return ;
return;
}
// check the steamguard
......@@ -140,12 +140,17 @@ public class AuthenticatorSteamGuardViewModel : ViewModelBase
var auth = new SteamAuthenticator
{
SecretKey = secret, Serial = serial, SteamData = PhoneImportSteamGuard, DeviceId = deviceId
SecretKey = secret,
Serial = serial,
SteamData = PhoneImportSteamGuard,
DeviceId = deviceId
};
await _saveAuth.Invoke(new AuthenticatorDTO()
{
Name = $"(Steam){ImportAuthNewName}", Value = auth, Created = DateTimeOffset.Now,
Name = $"(Steam){ImportAuthNewName}",
Value = auth,
Created = DateTimeOffset.Now,
});
}
}
\ No newline at end of file
......@@ -47,7 +47,7 @@ public class ShowSteamDataViewModel : ViewModelBase
public ShowSteamDataViewModel()
{
}
public ShowSteamDataViewModel(IAuthenticatorDTO authenticatorDto)
......@@ -68,5 +68,4 @@ public class ShowSteamDataViewModel : ViewModelBase
//await IWindowManager.Instance.ShowTaskDialogAsync(viewModel, Strings.LocalAuth_ShowAuthInfo);
}
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ public sealed partial class SteamLoginImportViewModel
bool _isFirstLogin = true;
bool _isConfirmMailUrl;
readonly ISteamAccountService _steamAccountService;
readonly Func<IAuthenticatorDTO, Task> _saveAuth;
......@@ -25,7 +25,7 @@ public sealed partial class SteamLoginImportViewModel
_steamAccountService = Ioc.Get<ISteamAccountService>();
_saveAuth = (authenticatorDto) => Task.CompletedTask;
}
public SteamLoginImportViewModel(Func<IAuthenticatorDTO, Task> saveAuthFunc)
{
_steamAccountService = Ioc.Get<ISteamAccountService>();
......@@ -33,7 +33,7 @@ public sealed partial class SteamLoginImportViewModel
}
SteamAuthenticator steamAuthenticator = new();
SteamLoginState _steamLoginState = new();
SteamAuthenticator.EnrollState _enrollState = new SteamAuthenticator.EnrollState();
......@@ -68,7 +68,7 @@ public sealed partial class SteamLoginImportViewModel
_steamLoginState.Password = PasswordText;
_steamLoginState.Language = ResourceService.GetCurrentCultureSteamLanguageName();
_IsLogining = true;
await _steamAccountService.DoLoginV2Async(_steamLoginState);
_isFirstLogin = false;
}
......@@ -81,7 +81,7 @@ public sealed partial class SteamLoginImportViewModel
}
else
_steamLoginState.CaptchaText = CaptchaCodeText;
await _steamAccountService.DoLoginV2Async(_steamLoginState);
CaptchaCodeText = null;
......@@ -97,7 +97,7 @@ public sealed partial class SteamLoginImportViewModel
_steamLoginState.EmailCode = EmailAuthText;
await _steamAccountService.DoLoginV2Async(_steamLoginState);
EmailAuthText = null;
EmailDomainText = null;
}
......@@ -106,7 +106,7 @@ public sealed partial class SteamLoginImportViewModel
{
return await steamAuthenticator.AddAuthenticatorAsync(_enrollState);
}
public async Task<bool> FinalizeAddAuthenticatorAsync()
{
if (string.IsNullOrEmpty(PhoneCodeText))
......@@ -115,10 +115,10 @@ public sealed partial class SteamLoginImportViewModel
}
else
_enrollState.ActivationCode = PhoneCodeText;
await steamAuthenticator.FinalizeAddAuthenticatorAsync(_enrollState);
PhoneCodeText = null;
return _steamLoginState.Success;
}
......@@ -151,7 +151,7 @@ public sealed partial class SteamLoginImportViewModel
SelectIndex = 3;
}
}
/// <summary>
/// 检查登陆是否成功
/// </summary>
......@@ -207,7 +207,7 @@ public sealed partial class SteamLoginImportViewModel
return;
}
_IsLogining = true;
try
{
if (ToastService.IsSupported)
......@@ -227,7 +227,7 @@ public sealed partial class SteamLoginImportViewModel
}
else if (_steamLoginState.RequiresEmailAuth)
{
await LoginSteamWithEmailCodeAsync();
await LoginSteamWithEmailCodeAsync();
}
if (await CheckLoginResult())
......@@ -235,7 +235,7 @@ public sealed partial class SteamLoginImportViewModel
_enrollState.AccessToken ??= _steamLoginState.AccessToken;
_enrollState.RefreshToken ??= _steamLoginState.RefreshToken;
_enrollState.SteamId ??= _steamLoginState.SteamId.ToString();
if (_enrollState.RequiresActivation)
{
if (await FinalizeAddAuthenticatorAsync())
......@@ -268,11 +268,11 @@ public sealed partial class SteamLoginImportViewModel
Toast.Show(ToastIcon.Warning, AppResources.Warning_PleaseEnterTel);
return;
}
var reslut = await steamAuthenticator.AddPhoneNumberAsync(_enrollState.AccessToken!,
_enrollState.SteamId,
PhoneNumberText, _isConfirmMailUrl);
if (!string.IsNullOrEmpty(reslut))
{
Toast.Show(ToastIcon.Info, reslut);
......
......@@ -10,7 +10,7 @@ public sealed partial class SteamLoginImportViewModel : ViewModelBase
{
[Reactive]
public bool IsLoading { get; set; }
private int index;
public int SelectIndex
......
......@@ -235,7 +235,7 @@ public sealed partial class SteamTradePageViewModel
// _steamClient.Logout();
// }
// }
// void RefreshConfirmationsList()
// {
// var items = _confirmationsSourceList.Items.Where(s => s.IsOperate == 0);
......
......@@ -92,5 +92,4 @@ public sealed partial class SteamTradePageViewModel : ViewModelBase
}
public bool IsConfirmationsAny => Confirmations.Any_Nullable();
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ public partial class SteamTradePage : UserControl
public SteamTradePage()
{
InitializeComponent();
PasswordText.KeyUp += (_, e) =>
{
if (e.Key != Avalonia.Input.Key.Return) return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册