This commit is contained in:
andrei-mihnea-cerbu
2024-04-08 13:37:58 +03:00
parent 333ad8be09
commit 370bbdedcd
164 changed files with 3915 additions and 161 deletions
@@ -0,0 +1,75 @@
@page "/reset-password/{role}"
@using HealthcareManagerUI.Models
@using HealthcareManagerUI.Services.Authentication
@using HealthcareManagerUI.Components.Layout
@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 UserRegisterModel? userResetPasswordModel { get; set; }
protected override void OnInitialized()
{
userResetPasswordModel ??= new();
}
[Parameter] public string Role { get; set; }
private string errorMessage { get; set; }
private void ClearErrorMessage()
{
errorMessage = string.Empty;
}
private async Task HandleResetPassword()
{
var response = Role switch
{
"doctor" => await AuthenticationService.ResetDoctorPassword(userResetPasswordModel),
"patient" => await AuthenticationService.ResetPatientPassword(userResetPasswordModel),
_ => null
};
if (response.StatusCode >= 200 && response.StatusCode <= 399)
{
NavigationManager.NavigateTo($"/login/{Role}");
}
else
{
errorMessage = response.Message;
}
}
}