WorkTracker/Components/Pages/ChangePassword.razor

53 lines
1.4 KiB
Text
Raw Permalink Normal View History

@page "/change-password"
@attribute [Authorize]
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components
2026-04-20 14:11:18 +02:00
@using Microsoft.Extensions.Options
@using WorkTracker.Configuration
@inject IOptions<AppAuthOptions> AppAuthOptions
@inject NavigationManager Navigation
<PageTitle>Change Password</PageTitle>
2026-04-20 14:11:18 +02:00
@if (!AppAuthOptions.Value.Enabled)
{
<p>Redirecting...</p>
}
else
{
<h1>Change password</h1>
@if (!string.IsNullOrWhiteSpace(Error))
{
<div class="alert alert-danger" role="alert">@Error</div>
}
<form method="post" action="/api/change-password" class="d-flex flex-column gap-3" style="max-width: 420px;">
<div>
<label for="newPassword" class="form-label">New password</label>
<input id="newPassword" name="newPassword" type="password" autocomplete="new-password" class="form-control" required />
</div>
<div>
<label for="confirmPassword" class="form-label">Confirm new password</label>
<input id="confirmPassword" name="confirmPassword" type="password" autocomplete="new-password" class="form-control" required />
</div>
<button type="submit" class="btn btn-primary">Change password</button>
</form>
2026-04-20 14:11:18 +02:00
}
@code {
[SupplyParameterFromQuery]
public string? Error { get; set; }
2026-04-20 14:11:18 +02:00
protected override void OnInitialized()
{
if (!AppAuthOptions.Value.Enabled)
{
Navigation.NavigateTo("/", forceLoad: true);
}
}
}