From a80aa4b2258b2006594a0cf698fcceaffd7a9d49 Mon Sep 17 00:00:00 2001 From: Michiel Post Date: Fri, 18 Oct 2024 11:11:56 +0200 Subject: [PATCH] Password check message improvements --- .../Pages/GenerateWalletPage.razor | 4 ++++ .../Pages/GenerateWalletPage.razor.cs | 20 ++++++++++++++----- .../Shared/AddGenerateWalletComponent.razor | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/aoWebWallet/Pages/GenerateWalletPage.razor b/src/aoWebWallet/Pages/GenerateWalletPage.razor index 5627544..d4971f5 100644 --- a/src/aoWebWallet/Pages/GenerateWalletPage.razor +++ b/src/aoWebWallet/Pages/GenerateWalletPage.razor @@ -20,6 +20,8 @@ Adornment="Adornment.End" AdornmentIcon="@PasswordInputIcon" OnAdornmentClick="TogglePasswordVisibility" + Error="@(!string.IsNullOrEmpty(PasswordError))" + ErrorText="@PasswordError" /> private bool PasswordVisible { get; set; } = false; private InputType PasswordInput { get; set; } = InputType.Password; private string PasswordInputIcon { get; set; } = Icons.Material.Filled.VisibilityOff; + private string PasswordError { get; set; } = string.Empty; + private string ConfirmPasswordError { get; set; } = string.Empty; private void TogglePasswordVisibility() { @@ -30,28 +32,36 @@ private void TogglePasswordVisibility() private void GenerateWallet() { + PasswordError = string.Empty; + ConfirmPasswordError = string.Empty; + if (string.IsNullOrWhiteSpace(Password) || string.IsNullOrWhiteSpace(ConfirmPassword)) { - Snackbar.Add("Please enter and confirm your password.", Severity.Warning); + PasswordError = "Please enter and confirm your password."; return; } if (Password != ConfirmPassword) { - Snackbar.Add("Passwords do not match.", Severity.Error); + ConfirmPasswordError = "Passwords do not match."; return; } if (Password.Length < 6) { - Snackbar.Add("Password must be at least 6 characters long.", Severity.Warning); + PasswordError = "Password must be at least 6 characters long."; + return; + } + + if(BindingContext.WalletList.Data?.Any(x => x.NeedsUnlock) ?? true) + { + PasswordError = "Unable to set a new password. Please unlock your wallet first."; return; } BindingContext.SecretKey = Password; - // TODO: Implement wallet generation logic here - Snackbar.Add("Wallet generated successfully!", Severity.Success); + Snackbar.Add("Password set successfully!", Severity.Success); } } } diff --git a/src/aoWebWallet/Shared/AddGenerateWalletComponent.razor b/src/aoWebWallet/Shared/AddGenerateWalletComponent.razor index fb8e341..1a7d0f3 100644 --- a/src/aoWebWallet/Shared/AddGenerateWalletComponent.razor +++ b/src/aoWebWallet/Shared/AddGenerateWalletComponent.razor @@ -13,7 +13,7 @@ @Progress -
+
Create aoWW Wallet