TourIAm/TIAMSharedUI/Pages/RenewPassword.razor

136 lines
4.9 KiB
Plaintext

@page "/renewpassword/{userId}/{renewToken}"
@inherits BasePageComponent
@using TIAM.Models.Dtos.Users
@using TIAM.Services
@using TIAMSharedUI.Shared.Components.BaseComponents
@using BlazorAnimation
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Models.PageModels;
@using TIAMSharedUI.Pages.Components;
@using TIAMSharedUI.Pages.User.CardComponents
@using TIAMWebApp.Shared.Application.Services
@inject IUserDataService UserDataService
@inject AdminSignalRClient AdminSignalRClient
<PageTitle>Renew password</PageTitle>
<div class="text-center m-5">
<h1>Renew password</h1>
<h2 style="font-size:small">Good to see you again!</h2>
</div>
<div class="container mt-3">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-12 col-sm-6 px-5">
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Slow" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card glass inputwizardwrapper my-5">
@{
if (!isFormHidden)
{
<div class="wrapper">
<div class="my-logo">
<img src="_content/TIAMSharedUI/images/png-logo-0.png" alt="">
</div>
<div class="text-center mt-4 name">
@_localizer["LoginTitleText"]
</div>
<UserCardComponent DataChanged="SendForm" Context="user" IsForgotten="true" />
<div class="text-center fs-6">
No account yet? <a href="register">Sign up here!</a>
</div>
<div class="text-center fs-6">
Figured it out? <a href="login">Back to login!</a>
</div>
</div>
}
else
{
<div class="wrapper">
<div class="my-logo">
<img src="_content/TIAMSharedUI/images/png-logo-0.png" alt="">
</div>
<div class="text-center mt-4 name">
@_localizer["LoginTitleText"]
</div>
<p>@resultMsg</p>
<div class="text-center fs-6">
No account yet? <a href="register">Sign up here!</a>
</div>
<div class="text-center fs-6">
Figured it out? <a href="login">Back to login!</a>
</div>
</div>
}
}
</div>
</Animation>
</div>
<div class="col-12 col-sm-6 px-5">
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<p>
Welcome back to Budapest Airport Transfer Services! We're delighted to have you return to our platform. Please sign in to access your account and manage your bookings effortlessly. If you're new here, feel free to create an account to unlock exclusive benefits and enjoy a seamless booking experience.
</p>
</Animation>
</div>
</div>
</div>
@code {
[Parameter] public string? userId { get; set; } = "";
[Parameter] public string? renewToken { get; set; } = "";
private bool isFormHidden = true;
string resultMsg = "";
private UserModelDtoDetail? user = new UserModelDtoDetail();
protected override async Task OnInitializedAsync()
{
if (userId != null && renewToken != null)
{
string msg = await UserDataService.ValidateForgotPasswordToken(Guid.Parse(userId), renewToken);
if (msg == "Success")
{
user = await UserDataService.GetUserDetailByIdAsync(Guid.Parse(userId));
isFormHidden = false;
}
else
{
isFormHidden = true;
resultMsg = msg;
}
}
await base.OnInitializedAsync();
}
protected override async Task OnParametersSetAsync()
{
//validate Token
await base.OnParametersSetAsync();
}
private void SendForm(bool isSuccess)
{
if (isSuccess)
{
resultMsg = "Successful, now you can go to the login page and log in with your new password!";
}
else
{
resultMsg = "Password wasn't saved. Please try again sending the forgotten password email. ";
}
}
}