Skip to content

Commit

Permalink
Passcode preparations
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisreimann committed Jan 26, 2025
1 parent cbceadb commit 29bc2a4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
19 changes: 18 additions & 1 deletion BTCPayApp.UI/Pages/Settings/ChangePasscodePage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@
}
</div>
<Passcode OnPasscodeEntered="HandlePasscodeEntered" />
@if (HasPasscode)
{
<button class="btn btn-outline-danger" type="button" @onclick="RemovePasscode">
Remove passcode
</button>
}
</ValidationEditContext>
</section>

@code {
private PasscodeModel Model { get; set; } = new();
private BTCPayAppConfig? _config;
private ValidationEditContext? _validationEditContext;
private bool HasPasscode => !string.IsNullOrEmpty(_config?.Passcode);

protected override async Task OnInitializedAsync()
{
Expand Down Expand Up @@ -95,9 +102,19 @@
}
}

// TODO: Guard with passcode entering
private async Task RemovePasscode()
{
if (HasPasscode)
{
_config!.Passcode = null;
await ConfigProvider.Set(BTCPayAppConfig.Key, _config, true);
}
}

private string GetTitle() => Model.Mode switch
{
PasscodeMode.Set => $"{(string.IsNullOrEmpty(_config!.Passcode) ? "Set" : "Change")} Passcode",
PasscodeMode.Set => $"{(HasPasscode ? "Set" : "Change")} Passcode",
PasscodeMode.Confirm => "Confirm Passcode",
_ => throw new ArgumentOutOfRangeException()
};
Expand Down
6 changes: 6 additions & 0 deletions BTCPayApp.UI/Pages/Settings/ChangePasscodePage.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
.container ::deep form > div {
min-height: 8rem;
}

.container .btn-outline-danger {
width: 100%;
max-width: 28rem;
margin-top: var(--btcpay-space-xl);
}
35 changes: 7 additions & 28 deletions BTCPayApp.UI/Pages/Settings/IndexPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -173,31 +173,20 @@
<Icon Symbol="caret-right"/>
</a>
</li>
@*<li class="list-group-item">
<a href="@Routes.ChangePasscode">
<Icon Symbol="key"/>
<span>@(HasPasscode ? "Change" : "Set") Passcode</span>
<Icon Symbol="caret-right"/>
</a>
</li>*@
<li class="list-group-item">
<a href="@Routes.ChangePassword">
<Icon Symbol="dots" class="p-2"/>
<span>Change Password</span>
<Icon Symbol="caret-right"/>
</a>
</li>
@*
<li class="list-group-item">
<a href="@Routes.ChangePasscode">
<Icon Symbol="key"/>
<span>@(HasPasscode ? "Change" : "Set") Passcode</span>
<Icon Symbol="caret-right"/>
</a>
</li>
@if (HasPasscode)
{
<li class="list-group-item">
<button class="btn btn-link text-danger" type="button" @onclick="RemovePasscode">
<Icon Symbol="key" class="text-body"/>
<span class="me-auto">Remove passcode</span>
</button>
</li>
}
*@
</ul>
</div>

Expand Down Expand Up @@ -306,16 +295,6 @@
_biometricAuthAvailable = await Fingerprint.IsAvailableAsync();
}

// TODO: Guard with passcode entering
private async Task RemovePasscode()
{
if (HasPasscode)
{
_config!.Passcode = null;
await ConfigProvider.Set(BTCPayAppConfig.Key, _config, true);
}
}

private void SetTheme(string theme)
{
Model.Theme = theme;
Expand Down

0 comments on commit 29bc2a4

Please sign in to comment.