-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ba2cfb
commit b9ea0d6
Showing
17 changed files
with
232 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@page "/import-wallet" | ||
@inherits MvvmComponentBase<MainViewModel> | ||
@inject ISnackbar Snackbar | ||
|
||
<PageTitle>Import Wallet - @Program.PageTitlePostFix</PageTitle> | ||
|
||
<MudContainer Class="mt-2 px-8" MaxWidth="MaxWidth.False"> | ||
<MudBreadcrumbs Class="breadcrumbs-aoww" Items="_items"></MudBreadcrumbs> | ||
|
||
@if (BindingContext.SecretKey == null) | ||
{ | ||
if (BindingContext.CheckNeedsUnlock()) | ||
{ | ||
<UnlockWalletComponent /> | ||
} | ||
else | ||
{ | ||
<SetSecretKeyComponent /> | ||
} | ||
} | ||
else | ||
{ | ||
<AddUploadWalletComponent></AddUploadWalletComponent> | ||
} | ||
</MudContainer> | ||
|
||
@code { | ||
private List<BreadcrumbItem> _items = new List<BreadcrumbItem> | ||
{ | ||
new BreadcrumbItem("Home", href: "/"), | ||
new BreadcrumbItem("Import Wallet", href: null, disabled: true) | ||
}; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
WatchDataLoaderVM(BindingContext.WalletList); | ||
WatchProp(nameof(BindingContext.SecretKey)); | ||
|
||
base.OnInitialized(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using aoWebWallet.ViewModels; | ||
using Microsoft.AspNetCore.Components; | ||
using MudBlazor; | ||
|
||
namespace aoWebWallet.Pages | ||
{ | ||
public partial class GenerateWalletPage : MvvmComponentBase<MainViewModel> | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
|
||
<AddWalletComponent /> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
@using aoWebWallet.Models | ||
@inherits MvvmComponentBase<MainViewModel> | ||
@inject ISnackbar Snackbar | ||
|
||
<MudPaper Class="pa-4 mt-4" Elevation="3"> | ||
<MudText Typo="Typo.h4" Class="mb-4">Generate Wallet</MudText> | ||
<MudText Typo="Typo.body1" Class="mb-4">Enter a password to encrypt your wallet. The password must be at least 6 characters long.</MudText> | ||
|
||
<MudTextField @bind-Value="Password" | ||
Label="Password" | ||
Variant="Variant.Outlined" | ||
InputType="@PasswordInput" | ||
Adornment="Adornment.End" | ||
AdornmentIcon="@PasswordInputIcon" | ||
OnAdornmentClick="TogglePasswordVisibility" | ||
Error="@(!string.IsNullOrEmpty(PasswordError))" | ||
ErrorText="@PasswordError" /> | ||
|
||
<MudTextField @bind-Value="ConfirmPassword" | ||
Label="Confirm Password" | ||
Variant="Variant.Outlined" | ||
InputType="@PasswordInput" | ||
Adornment="Adornment.End" | ||
AdornmentIcon="@PasswordInputIcon" | ||
OnAdornmentClick="TogglePasswordVisibility" | ||
Error="@(!string.IsNullOrEmpty(ConfirmPasswordError))" | ||
ErrorText="@ConfirmPasswordError" /> | ||
|
||
<MudButton Variant="Variant.Filled" | ||
Color="Color.Primary" | ||
OnClick="SetSecretKey" | ||
Class="mt-4"> | ||
Generate Wallet | ||
</MudButton> | ||
</MudPaper> | ||
|
||
|
||
|
||
@code { | ||
|
||
private string Password { get; set; } = string.Empty; | ||
private string ConfirmPassword { get; set; } = string.Empty; | ||
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() | ||
{ | ||
if (PasswordVisible) | ||
{ | ||
PasswordVisible = false; | ||
PasswordInputIcon = Icons.Material.Filled.VisibilityOff; | ||
PasswordInput = InputType.Password; | ||
} | ||
else | ||
{ | ||
PasswordVisible = true; | ||
PasswordInputIcon = Icons.Material.Filled.Visibility; | ||
PasswordInput = InputType.Text; | ||
} | ||
} | ||
|
||
private void SetSecretKey() | ||
{ | ||
PasswordError = string.Empty; | ||
ConfirmPasswordError = string.Empty; | ||
|
||
if (string.IsNullOrWhiteSpace(Password) || string.IsNullOrWhiteSpace(ConfirmPassword)) | ||
{ | ||
PasswordError = "Please enter and confirm your password."; | ||
return; | ||
} | ||
|
||
if (Password != ConfirmPassword) | ||
{ | ||
ConfirmPasswordError = "Passwords do not match."; | ||
return; | ||
} | ||
|
||
if (Password.Length < 6) | ||
{ | ||
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; | ||
|
||
Snackbar.Add("Password set successfully!", Severity.Success); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ | |
{ | ||
await BindingContext.TriggerUnlock(); | ||
|
||
this.StateHasChanged(); | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.