70 lines
2.3 KiB
Plaintext
70 lines
2.3 KiB
Plaintext
@page "/reset-password/{role}"
|
|
@using HealthcareManagerUiWebAssem.Models
|
|
@using HealthcareManagerUiWebAssem.Services.Authentication
|
|
|
|
@layout AuthLayout
|
|
|
|
@inject IAuthenticationService AuthenticationService
|
|
@inject NavigationManager NavigationManager
|
|
|
|
<head>
|
|
<title>Reset your password</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
</head>
|
|
<link rel="stylesheet" href="/LoginPage.css"/>
|
|
<link rel="stylesheet" href="/bootstrap/dist/css/bootstrap.min.css"/>
|
|
|
|
<EditForm Model="userResetPasswordModel" OnValidSubmit="@HandleResetPassword" FormName="ResetPasswordForm" class="login-form container mt-5">
|
|
<DataAnnotationsValidator/>
|
|
<ValidationSummary/>
|
|
|
|
<div class="card shadow-lg">
|
|
<div class="card-body">
|
|
<h3 class="card-title text-center mb-3">Register</h3>
|
|
<div class="form-group mb-3">
|
|
<InputText id="email" class="form-control" placeholder="Email" @bind-Value="userResetPasswordModel!.Email"></InputText>
|
|
</div>
|
|
<div class="form-group mb-3">
|
|
<InputText id="password" class="form-control" type="password" placeholder="New Password" @bind-Value="userResetPasswordModel!.Password"></InputText>
|
|
</div>
|
|
<div class="button-container">
|
|
<button type="submit" class="btn btn-primary w-100 mb-3">Reset Password</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</EditForm>
|
|
|
|
<AlertMessage ErrorMessage="@errorMessage"/>
|
|
|
|
@code {
|
|
[SupplyParameterFromForm] public UserLoginModel? userResetPasswordModel { get; set; }
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
userResetPasswordModel ??= new UserLoginModel();
|
|
}
|
|
|
|
[Parameter] public string Role { get; set; }
|
|
private string errorMessage { get; set; }
|
|
|
|
private void ClearErrorMessage()
|
|
{
|
|
errorMessage = string.Empty;
|
|
}
|
|
|
|
private async Task HandleResetPassword()
|
|
{
|
|
userResetPasswordModel.UserType = Role;
|
|
var response = await AuthenticationService.ResetPassword(userResetPasswordModel);
|
|
|
|
if (response.StatusCode >= 200 && response.StatusCode <= 399)
|
|
{
|
|
NavigationManager.NavigateTo($"/login/{Role}");
|
|
}
|
|
else
|
|
{
|
|
errorMessage = response.Message;
|
|
}
|
|
}
|
|
|
|
} |