Files
FACULTATE-HEALTHCARE_MANAGER/frontend/Pages/Anonymous/ResetPassword.razor
T
2024-05-21 12:10:53 +03:00

44 lines
1.3 KiB
Plaintext

@page "/reset-password"
@inject IAuthenticationService AuthenticationService
@inject NavigationManager Navigation
@layout AuthLayout
<h3>Reset Password</h3>
@if (!string.IsNullOrEmpty(_errorMessage))
{
<div class="alert alert-danger mt-2">@_errorMessage</div>
}
<EditForm Model="_resetPasswordModel" OnValidSubmit="HandleResetPassword">
<div class="form-group">
<label>Email:</label>
<InputText class="form-control" @bind-Value="_resetPasswordModel.Email"/>
</div>
<div class="form-group">
<label>New Password:</label>
<InputText class="form-control" @bind-Value="_resetPasswordModel.Password" type="password"/>
</div>
<button type="submit" class="btn btn-primary">Reset Password</button>
</EditForm>
@code {
private readonly ResetPasswordModel _resetPasswordModel = new();
private string _errorMessage = string.Empty;
private async Task HandleResetPassword()
{
_errorMessage = string.Empty;
var response = await AuthenticationService.ResetPassword(_resetPasswordModel);
if (response.StatusCode == 200)
{
Navigation.NavigateTo("/login", true);
}
else
{
_errorMessage = response.Message; // Display error message
}
}
}