This commit is contained in:
rmbgame
2021-05-23 14:35:51 +08:00
parent 2a450c237d
commit 47c06f2b9a
12 changed files with 249 additions and 57 deletions
@@ -23,6 +23,10 @@
</Design.PreviewWith>
<!--https://github.com/microsoft/fluentui-system-icons/blob/master/icons.md-->
<Styles.Resources>
<StreamGeometry x:Key="ShieldLockDrawing">
M8.35464 2.14678C8.15946 1.95123 7.84268 1.95105 7.64728 2.14638C6.40416 3.38902 5.02923 4 3.5 4C3.22386 4 3 4.22386 3 4.5V7.50126C3 10.4242 4.35378 12.4971 7 13.6523V10C7 9.06808 7.63739 8.28503 8.5 8.06301V8C8.5 6.34315 9.84315 5 11.5 5C12.0464 5 12.5587 5.14609 13 5.40135V4.5C13 4.22386 12.7761 4 12.5 4C10.9689 4 9.5947 3.38913 8.35464 2.14678ZM9.5 9V8C9.5 6.89543 10.3954 6 11.5 6C12.6046 6 13.5 6.89543 13.5 8V9H14C14.5523 9 15 9.44772 15 10V14C15 14.5523 14.5523 15 14 15H9C8.44771 15 8 14.5523 8 14V10C8 9.44772 8.44772 9 9 9H9.5ZM10.5 8V9H12.5V8C12.5 7.44772 12.0523 7 11.5 7C10.9477 7 10.5 7.44772 10.5 8ZM12.25 12C12.25 11.5858 11.9142 11.25 11.5 11.25C11.0858 11.25 10.75 11.5858 10.75 12C10.75 12.4142 11.0858 12.75 11.5 12.75C11.9142 12.75 12.25 12.4142 12.25 12Z
</StreamGeometry>
<StreamGeometry x:Key="GridDrawing">
M8.75 13C9.99264 13 11 14.0074 11 15.25V18.75C11 19.9926 9.99264 21 8.75 21H5.25C4.00736 21 3 19.9926 3 18.75V15.25C3 14.0074 4.00736 13 5.25 13H8.75ZM18.75 13C19.9926 13 21 14.0074 21 15.25V18.75C21 19.9926 19.9926 21 18.75 21H15.25C14.0074 21 13 19.9926 13 18.75V15.25C13 14.0074 14.0074 13 15.25 13H18.75ZM8.75 3C9.99264 3 11 4.00736 11 5.25V8.75C11 9.99264 9.99264 11 8.75 11H5.25C4.00736 11 3 9.99264 3 8.75V5.25C3 4.00736 4.00736 3 5.25 3H8.75ZM18.75 3C19.9926 3 21 4.00736 21 5.25V8.75C21 9.99264 19.9926 11 18.75 11H15.25C14.0074 11 13 9.99264 13 8.75V5.25C13 4.00736 14.0074 3 15.25 3H18.75Z
</StreamGeometry>
@@ -3,6 +3,7 @@ using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using System.Application.Services;
using System.Application.UI.ViewModels;
using System.Collections.Generic;
using System.Properties;
@@ -10,9 +11,11 @@ namespace System.Application.UI.Views.Windows
{
public class AddAuthWindow : FluentWindow
{
private AddAuthWindowViewModel? vm;
public AddAuthWindow() : base()
{
InitializeComponent();
vm = this.DataContext as AddAuthWindowViewModel;
#if DEBUG
this.AttachDevTools();
#endif
@@ -50,7 +53,7 @@ namespace System.Application.UI.Views.Windows
{
if (s != null && s.Result.Length > 0)
{
AuthService.Current.ImportAuthenticatorFile(s.Result[0]);
vm.ImportSteamPlusPlusV2(s.Result[0]);
}
});
}
@@ -70,7 +73,7 @@ namespace System.Application.UI.Views.Windows
{
if (s != null && s.Result.Length > 0)
{
AuthService.Current.LoadSteamToolsV1Authenticator(s.Result[0]);
vm.ImportSteamPlusPlusV1(s.Result[0]);
}
});
}
@@ -91,7 +94,7 @@ namespace System.Application.UI.Views.Windows
{
if (s != null && s.Result.Length > 0)
{
AuthService.Current.ImportSDAFile(s.Result[0]);
vm.ImportSDA(s.Result[0]);
}
});
}
@@ -111,7 +114,7 @@ namespace System.Application.UI.Views.Windows
{
if (s != null && s.Result.Length > 0)
{
AuthService.Current.ImportWinAuthenticators(s.Result[0]);
vm.ImportWinAuth(s.Result[0]);
}
});
@@ -1,10 +1,11 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Markup.Xaml;
namespace System.Application.UI.Views.Windows
{
public class PasswordWindow : FluentWindow
public class PasswordWindow : Window
{
public PasswordWindow() : base()
{
@@ -18,5 +19,11 @@ namespace System.Application.UI.Views.Windows
{
AvaloniaXamlLoader.Load(this);
}
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome;
}
}
}
@@ -1,5 +1,6 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Markup.Xaml;
using Avalonia.Styling;
using System.Reflection;
@@ -19,7 +20,6 @@ namespace System.Application.UI.Views.Windows
//}
InitializeComponent();
this.ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome;
#if DEBUG
this.AttachDevTools();
#endif
@@ -29,5 +29,11 @@ namespace System.Application.UI.Views.Windows
{
AvaloniaXamlLoader.Load(this);
}
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome;
}
}
}
@@ -73,13 +73,31 @@ namespace System.Application.Services
}
}
public async Task<bool> HasPasswordEncryptionShowPassWordWindow()
/// <summary>
/// 是否设置了密码加密
/// </summary>
/// <returns></returns>
public async Task<bool> HasPasswordEncryption()
{
var auths = await repository.GetAllSourceAsync();
if (!auths.Any_Nullable())
{
return false;
}
return repository.HasSecondaryPassword(auths);
}
/// <summary>
/// 是否设置了密码加密且弹出解密框
/// </summary>
/// <returns></returns>
public async Task<(bool success, string? password)> HasPasswordEncryptionShowPassWordWindow()
{
var auths = await repository.GetAllSourceAsync();
if (!auths.Any_Nullable())
{
return (false, null);
}
var hasPassword = repository.HasSecondaryPassword(auths);
if (hasPassword)
{
@@ -87,15 +105,15 @@ namespace System.Application.Services
var list = await repository.ConvertToList(auths, password);
if (list.Any_Nullable())
{
return true;
return (true, password);
}
Toast.Show(AppResources.LocalAuth_ProtectionAuth_PasswordError);
return false;
return (false, null);
}
else
{
//没有密码直接成功
return true;
//没有设置密码直接成功
return (true, null);
}
}
@@ -108,7 +126,7 @@ namespace System.Application.Services
/// <summary>
/// WinAuth令牌导入
/// </summary>
public void ImportWinAuthenticators(string file)
public void ImportWinAuthenticators(string file, bool isLocal, string? password)
{
StringBuilder lines = new StringBuilder();
bool retry;
@@ -124,7 +142,7 @@ namespace System.Application.Services
try
{
using var sr = new StringReader(lines.ToString());
string line;
string? line;
while ((line = sr.ReadLine()) != null)
{
linenumber++;
@@ -282,7 +300,7 @@ namespace System.Application.Services
ToastService.Current.Notify(AppResources.LocalAuth_AddAuthSyncTip);
importedAuthenticator.Value.Sync();
AuthService.AddOrUpdateSaveAuthenticators(importedAuthenticator);
AuthService.AddOrUpdateSaveAuthenticators(importedAuthenticator, isLocal, password);
}
ToastService.Current.Notify(AppResources.LocalAuth_AddAuthSuccess);
}
@@ -300,7 +318,7 @@ namespace System.Application.Services
/// Steam APP令牌导入
/// </summary>
/// <returns>true if successful</returns>
public bool ImportSteamGuard(string name, string uuid, string steamGuard)
public bool ImportSteamGuard(string name, string uuid, string steamGuard, bool isLocal, string? password)
{
if (string.IsNullOrEmpty(uuid))
{
@@ -389,11 +407,11 @@ namespace System.Application.Services
{
Name = name,
Value = auth,
});
}, isLocal, password);
return true;
}
public bool ImportSDAFile(string mafile)
public bool ImportSDAFile(string mafile, bool isLocal, string? password)
{
string data;
if (File.Exists(mafile) == false || (data = File.ReadAllText(mafile)) == null)
@@ -453,37 +471,48 @@ namespace System.Application.Services
auth.SteamData = token.ToString(Newtonsoft.Json.Formatting.None);
winAuth.Value = auth;
AddOrUpdateSaveAuthenticators(winAuth);
AddOrUpdateSaveAuthenticators(winAuth,isLocal,password);
return true;
}
/// <summary>
/// 导入Steam++导出的令牌数据文件 V2
/// </summary>
public async void ImportAuthenticatorFile(string file, string? password = null)
public async void ImportAuthenticatorFile(string file, bool isLocal, string? password, string? exportPassword = null)
{
if (File.Exists(file))
{
var bt = await File.ReadAllBytesAsync(file);
var result = await repository.ImportAsync(null, bt);
Run:
var result = await repository.ImportAsync(password, bt);
if (result.resultCode == IGameAccountPlatformAuthenticatorRepository.ImportResultCode.Success)
{
foreach (var item in result.result)
{
await repository.InsertOrUpdateAsync(item, true);
AddOrUpdateSaveAuthenticators(new MyAuthenticator(item), isLocal, password);
}
ToastService.Current.Notify(AppResources.LocalAuth_AddAuthSuccess);
}
else if (result.resultCode == IGameAccountPlatformAuthenticatorRepository.ImportResultCode.PartSuccess)
{
foreach (var item in result.result)
{
await repository.InsertOrUpdateAsync(item, true);
AddOrUpdateSaveAuthenticators(new MyAuthenticator(item), isLocal, password);
}
Toast.Show(AppResources.LocalAuth_AddAuth_PartSuccess);
}
else if (result.resultCode == IGameAccountPlatformAuthenticatorRepository.ImportResultCode.IncorrectPwdOrIsNotLocal)
{
Toast.Show(AppResources.LocalAuth_ProtectionAuth_PasswordErrorTip);
password = await PasswordWindowViewModel.ShowPasswordDialog();
if (string.IsNullOrWhiteSpace(password))
{
goto Run;
}
}
else
{
Toast.Show(string.Format(AppResources.LocalAuth_ExportAuth_Error, result.resultCode));
@@ -491,7 +520,7 @@ namespace System.Application.Services
};
}
public void LoadSteamToolsV1Authenticator(string file)
public void ImportSteamToolsV1Authenticator(string file, bool isLocal, string? password)
{
var authString = File.ReadAllText(file).DecompressString();
if (!string.IsNullOrEmpty(authString))
@@ -515,7 +544,7 @@ namespace System.Application.Services
{
var wa = new MyAuthenticator();
wa.ReadXml(reader, null);
AddOrUpdateSaveAuthenticators(wa);
AddOrUpdateSaveAuthenticators(wa, isLocal, password);
}
}
else
@@ -527,15 +556,15 @@ namespace System.Application.Services
}
}
public static void AddOrUpdateSaveAuthenticators(GAPAuthenticatorDTO auth)
public static void AddOrUpdateSaveAuthenticators(GAPAuthenticatorDTO auth, bool isLocal, string? password)
{
AddOrUpdateSaveAuthenticators(new MyAuthenticator(auth));
AddOrUpdateSaveAuthenticators(new MyAuthenticator(auth), isLocal, password);
}
public static async void AddOrUpdateSaveAuthenticators(MyAuthenticator auth)
public static async void AddOrUpdateSaveAuthenticators(MyAuthenticator auth, bool isLocal, string? password)
{
var repository = DI.Get<IGameAccountPlatformAuthenticatorRepository>();
await repository.InsertOrUpdateAsync(auth.AuthenticatorData, false);
await repository.InsertOrUpdateAsync(auth.AuthenticatorData, isLocal, password);
if (Current.Authenticators.Items.Any(s => s.Id == auth.Id))
{
return;
@@ -543,6 +572,32 @@ namespace System.Application.Services
Current.Authenticators.AddOrUpdate(auth);
}
public static async void AddOrUpdateSaveAuthenticators(IEnumerable<MyAuthenticator> auths)
{
if (auths.Any_Nullable())
{
var repository = DI.Get<IGameAccountPlatformAuthenticatorRepository>();
var sources = await repository.GetAllSourceAsync();
if (!sources.Any_Nullable())
{
foreach (var item in auths)
{
AddOrUpdateSaveAuthenticators(item, false, null);
}
}
else
{
var hasLocal = repository.HasLocal(sources);
var result = await AuthService.Current.HasPasswordEncryptionShowPassWordWindow();
var password = result.password;
foreach (var item in auths)
{
AddOrUpdateSaveAuthenticators(item, hasLocal, password);
}
}
}
}
public static async void DeleteSaveAuthenticators(MyAuthenticator auth)
{
var repository = DI.Get<IGameAccountPlatformAuthenticatorRepository>();
+18
View File
@@ -1818,6 +1818,15 @@ namespace System.Application.UI.Resx {
}
}
/// <summary>
/// 查找类似 没有设置密码无法锁定令牌 的本地化字符串。
/// </summary>
public static string LocalAuth_LockError {
get {
return ResourceManager.GetString("LocalAuth_LockError", resourceCulture);
}
}
/// <summary>
/// 查找类似 编辑令牌 的本地化字符串。
/// </summary>
@@ -2223,6 +2232,15 @@ namespace System.Application.UI.Resx {
}
}
/// <summary>
/// 查找类似 锁定 的本地化字符串。
/// </summary>
public static string Lock {
get {
return ResourceManager.GetString("Lock", resourceCulture);
}
}
/// <summary>
/// 查找类似 登 录 的本地化字符串。
/// </summary>
@@ -708,6 +708,9 @@
<data name="LocalAuth_ImportFaild" xml:space="preserve">
<value>导入失败,请检查数据是否正确。</value>
</data>
<data name="LocalAuth_LockError" xml:space="preserve">
<value>没有设置密码无法锁定令牌</value>
</data>
<data name="LocalAuth_MenuName" xml:space="preserve">
<value>编辑令牌</value>
</data>
@@ -843,6 +846,9 @@
<data name="LocalAuth_WinAuthTip" xml:space="preserve">
<value>WinAuth是Windows的便携式开放源代码身份验证器,它提供基于计数器或基于时间的RFC 6238身份验证器和常见的实现。导入方法:从WinAuth导出txt文件之后在此选择从WinAuth导出的txt文件进行导入。</value>
</data>
<data name="Lock" xml:space="preserve">
<value>锁定</value>
</data>
<data name="Login" xml:space="preserve">
<value>登 录</value>
</data>
@@ -1313,4 +1319,4 @@
<data name="Welcome" xml:space="preserve">
<value>起始页</value>
</data>
</root>
</root>
@@ -24,8 +24,20 @@ namespace System.Application.UI.ViewModels
AddAuthCommand = ReactiveCommand.Create(AddAuthMenu_Click);
RefreshAuthCommand = ReactiveCommand.Create(() => AuthService.Current.Initialize(true));
EncryptionAuthCommand = ReactiveCommand.Create(ShowEncryptionAuthWindow);
ExportAuthCommand = ReactiveCommand.Create(ShowExportAuthAuthWindow);
LockCommand = ReactiveCommand.Create(async () =>
{
var result = await AuthService.Current.HasPasswordEncryption();
if (result)
{
AuthService.Current.Authenticators.Clear();
Activation();
}
else
{
Toast.Show(AppResources.LocalAuth_LockError);
}
});
MenuItems = new ObservableCollection<MenuItemViewModel>()
{
@@ -34,15 +46,17 @@ namespace System.Application.UI.ViewModels
// Items = new[]
// {
new MenuItemViewModel(nameof(AppResources.Add)) { IconKey="AddDrawing",
Command= AddAuthCommand },
new MenuItemViewModel(nameof(AppResources.Encrypt)) {IconKey="LockDrawing",
Command =EncryptionAuthCommand },
Command = AddAuthCommand },
new MenuItemViewModel(nameof(AppResources.Encrypt)) {IconKey="ShieldLockDrawing",
Command = EncryptionAuthCommand },
//new MenuItemViewModel(nameof(AppResources.Edit)) { IconKey="EditDrawing" },
new MenuItemViewModel(nameof(AppResources.Export)) { IconKey="ExportDrawing",
Command= ExportAuthCommand },
Command = ExportAuthCommand },
new MenuItemViewModel(),
new MenuItemViewModel(nameof(AppResources.Lock)) {IconKey="LockDrawing",
Command = LockCommand },
new MenuItemViewModel(nameof(AppResources.Refresh)) {IconKey="RefreshDrawing",
Command= RefreshAuthCommand },
Command = RefreshAuthCommand },
//new MenuItemViewModel(),
//new MenuItemViewModel(nameof(AppResources.Encrypt)) {IconKey="LockDrawing" },
//new MenuItemViewModel(nameof(AppResources.CloudSync)) {IconKey="CloudDrawing" },
@@ -75,6 +89,8 @@ namespace System.Application.UI.ViewModels
public ReactiveCommand<Unit, Unit> EncryptionAuthCommand { get; }
public ReactiveCommand<Unit, Task> LockCommand { get; }
public ReactiveCommand<Unit, Unit> RefreshAuthCommand { get; }
public ReactiveCommand<Unit, Unit> ExportAuthCommand { get; }
@@ -137,7 +153,8 @@ namespace System.Application.UI.ViewModels
public async void ShowSteamAuthData(MyAuthenticator auth)
{
if (await AuthService.Current.HasPasswordEncryptionShowPassWordWindow())
var result = await AuthService.Current.HasPasswordEncryptionShowPassWordWindow();
if (result.success)
{
if (auth.AuthenticatorData.Value is GAPAuthenticatorValueDTO.SteamAuthenticator)
{
@@ -1,5 +1,6 @@
using ReactiveUI;
using System.Application.Models;
using System.Application.Repositories;
using System.Application.Services;
using System.Application.UI.Resx;
using System.IO;
@@ -13,20 +14,40 @@ namespace System.Application.UI.ViewModels
public class AddAuthWindowViewModel : WindowViewModel
{
readonly IHttpService httpService = DI.Get<IHttpService>();
readonly IGameAccountPlatformAuthenticatorRepository repository = DI.Get<IGameAccountPlatformAuthenticatorRepository>();
public AddAuthWindowViewModel() : base()
{
Title = ThisAssembly.AssemblyTrademark + " | " + AppResources.LocalAuth_AddAuth;
Initialize();
}
private GAPAuthenticatorValueDTO.SteamAuthenticator _SteamAuthenticator;
private GAPAuthenticatorValueDTO.SteamAuthenticator? _SteamAuthenticator;
private GAPAuthenticatorValueDTO.SteamAuthenticator.EnrollState _Enroll = new() { RequiresLogin = true };
private string? AuthPassword;
private bool AuthIsLocal;
public string AuthName { get; set; }
private async void Initialize()
{
var result = await AuthService.Current.HasPasswordEncryptionShowPassWordWindow();
if (result.success)
{
AuthPassword = result.password;
}
else
{
AuthPassword = null;
}
var auths = await repository.GetAllSourceAsync();
AuthIsLocal = repository.HasLocal(auths);
}
public string UUID { get; set; }
public string SteamGuard { get; set; }
public string? AuthName { get; set; }
public string? UUID { get; set; }
public string? SteamGuard { get; set; }
public bool RequiresLogin
{
@@ -53,7 +74,7 @@ namespace System.Application.UI.ViewModels
}
}
public string UserName
public string? UserName
{
get
{
@@ -65,7 +86,7 @@ namespace System.Application.UI.ViewModels
}
}
public string Password
public string? Password
{
get
{
@@ -149,7 +170,7 @@ namespace System.Application.UI.ViewModels
public void ImportSteamGuard()
{
if (AuthService.Current.ImportSteamGuard(AuthName, UUID, SteamGuard))
if (AuthService.Current.ImportSteamGuard(AuthName, UUID, SteamGuard, AuthIsLocal, AuthPassword))
{
ToastService.Current.Notify(AppResources.LocalAuth_AddAuthSuccess);
}
@@ -225,7 +246,7 @@ namespace System.Application.UI.ViewModels
{
Name = nameof(GamePlatform.Steam) + "(" + UserName + ")",
Value = _SteamAuthenticator
});
}, AuthIsLocal, AuthPassword);
RequiresActivation = true;
RevocationCode = _Enroll.RevocationCode;
@@ -261,5 +282,24 @@ namespace System.Application.UI.ViewModels
}
public void ImportWinAuth(string file)
{
AuthService.Current.ImportWinAuthenticators(file,AuthIsLocal,AuthPassword);
}
public void ImportSDA(string file)
{
AuthService.Current.ImportSDAFile(file, AuthIsLocal, AuthPassword);
}
public void ImportSteamPlusPlusV1(string file)
{
AuthService.Current.ImportSteamToolsV1Authenticator(file, AuthIsLocal, AuthPassword);
}
public void ImportSteamPlusPlusV2(string file)
{
AuthService.Current.ImportAuthenticatorFile(file, AuthIsLocal, AuthPassword);
}
}
}
@@ -2,6 +2,7 @@ using DynamicData;
using DynamicData.Binding;
using ReactiveUI;
using System.Application.Models;
using System.Application.Repositories;
using System.Application.Services;
using System.Application.UI.Resx;
using System.Collections.Generic;
@@ -36,6 +37,8 @@ namespace System.Application.UI.ViewModels
this.RaisePropertyChanged(nameof(IsConfirmationsEmpty));
this.RaisePropertyChanged(nameof(ConfirmationsConutMessage));
});
Initialize();
}
public AuthTradeWindowViewModel(MyAuthenticator auth) : this()
@@ -55,6 +58,25 @@ namespace System.Application.UI.ViewModels
Refresh_Click();
}
private string? AuthPassword;
private bool AuthIsLocal;
private async void Initialize()
{
var repository = DI.Get<IGameAccountPlatformAuthenticatorRepository>();
var result = await AuthService.Current.HasPasswordEncryptionShowPassWordWindow();
if (result.success)
{
AuthPassword = result.password;
}
else
{
AuthPassword = null;
}
var auths = await repository.GetAllSourceAsync();
AuthIsLocal = repository.HasLocal(auths);
}
#region LoginData
private string? _UserName;
public string? UserName
@@ -239,7 +261,7 @@ namespace System.Application.UI.ViewModels
{
IsLoggedIn = false;
_Authenticator.SessionData = null;
AuthService.AddOrUpdateSaveAuthenticators(MyAuthenticator);
AuthService.AddOrUpdateSaveAuthenticators(MyAuthenticator,AuthIsLocal,AuthPassword);
}
}
@@ -291,7 +313,7 @@ namespace System.Application.UI.ViewModels
ToastService.Current.Notify(AppResources.User_LoiginSuccess);
IsLoggedIn = true;
_Authenticator.SessionData = RememberMe ? steam.Session.ToString() : null;
AuthService.AddOrUpdateSaveAuthenticators(MyAuthenticator);
AuthService.AddOrUpdateSaveAuthenticators(MyAuthenticator, AuthIsLocal, AuthPassword);
}
try
{
@@ -311,7 +333,7 @@ namespace System.Application.UI.ViewModels
// 获取新交易后保存
if (!string.IsNullOrEmpty(_Authenticator.SessionData))
{
AuthService.AddOrUpdateSaveAuthenticators(MyAuthenticator);
AuthService.AddOrUpdateSaveAuthenticators(MyAuthenticator, AuthIsLocal, AuthPassword);
}
IsLoading = false;
}
@@ -563,7 +585,7 @@ namespace System.Application.UI.ViewModels
CancelComfirmAll = null;
RefreshConfirmationsList();
ToastService.Current.Notify(AppResources.LocalAuth_AuthTrade_ConfirmSuccess);
AuthService.AddOrUpdateSaveAuthenticators(MyAuthenticator);
AuthService.AddOrUpdateSaveAuthenticators(MyAuthenticator, AuthIsLocal, AuthPassword);
}
}
@@ -617,7 +639,7 @@ namespace System.Application.UI.ViewModels
CancelCancelAll = null;
RefreshConfirmationsList();
ToastService.Current.Notify(AppResources.LocalAuth_AuthTrade_ConfirmCancel);
AuthService.AddOrUpdateSaveAuthenticators(MyAuthenticator);
AuthService.AddOrUpdateSaveAuthenticators(MyAuthenticator, AuthIsLocal, AuthPassword);
}
}
@@ -18,15 +18,21 @@ namespace System.Application.UI.ViewModels
Initialize();
}
public async void Initialize()
private async void Initialize()
{
var result = await AuthService.Current.HasPasswordEncryptionShowPassWordWindow();
if (!result.success)
{
this.Close();
}
var auths = await repository.GetAllSourceAsync();
IsPasswordEncrypt = repository.HasSecondaryPassword(auths);
IsOnlyCurrentComputerEncrypt = repository.HasLocal(auths);
if (IsPasswordEncrypt)
{
//Password = "******";
//VerifyPassword = "******";
Password = result.password;
VerifyPassword = result.password;
}
}
@@ -60,10 +66,6 @@ namespace System.Application.UI.ViewModels
public async void EncryptionAuth()
{
if (!await AuthService.Current.HasPasswordEncryptionShowPassWordWindow())
{
return;
}
var auths = await repository.GetAllSourceAsync();
var hasPassword = repository.HasSecondaryPassword(auths);
var hasLocal = repository.HasLocal(auths);
@@ -51,8 +51,20 @@ namespace System.Application.UI.ViewModels
}
public void ExportAuth()
public async void ExportAuth()
{
var result = await AuthService.Current.HasPasswordEncryptionShowPassWordWindow();
if (!result.success)
{
this.Close();
}
if (string.IsNullOrEmpty(Path))
{
Toast.Show(AppResources.LocalAuth_ProtectionAuth_PathError);
return;
}
if (IsPasswordEncrypt)
{
if (string.IsNullOrWhiteSpace(VerifyPassword) && VerifyPassword != Password)