95 lines
3.1 KiB
Plaintext
95 lines
3.1 KiB
Plaintext
@page "/account/confirm-email"
|
|
@layout AuthenticationLayout
|
|
@using Indotalent.Shared.Consts
|
|
@using Microsoft.AspNetCore.Identity
|
|
@using Microsoft.AspNetCore.WebUtilities
|
|
@using System.Text
|
|
@using Indotalent.Data.Entities
|
|
@inject UserManager<ApplicationUser> UserManager
|
|
@inject NavigationManager Navigation
|
|
@inject ISnackbar Snackbar
|
|
|
|
<PageTitle>Confirming Email - @GlobalConsts.AppInitial</PageTitle>
|
|
|
|
<style>
|
|
.confirm-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
text-align: center;
|
|
}
|
|
|
|
.confirm-icon-wrapper {
|
|
width: 5rem;
|
|
height: 5rem;
|
|
border-radius: 50%;
|
|
background: #f5f3ff;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.confirm-title {
|
|
font-size: 1.5rem;
|
|
font-weight: 700;
|
|
color: #0f172a;
|
|
margin-bottom: 1rem;
|
|
}
|
|
</style>
|
|
|
|
<div class="confirm-container">
|
|
<div class="confirm-icon-wrapper">
|
|
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="#594AE2" stroke-width="1.75">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z" />
|
|
</svg>
|
|
</div>
|
|
|
|
<h2 class="confirm-title">Verifying Your Account</h2>
|
|
<MudProgressCircular Color="Color.Primary" Indeterminate="true" Size="Size.Large" Class="mb-4" />
|
|
<MudText Typo="Typo.body2" Style="color: #64748b;">Please wait while we validate your email address...</MudText>
|
|
</div>
|
|
|
|
@code {
|
|
[SupplyParameterFromQuery] public string? userId { get; set; }
|
|
[SupplyParameterFromQuery] public string? code { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(code))
|
|
{
|
|
Snackbar.Add("Invalid or expired confirmation link.", Severity.Error);
|
|
Navigation.NavigateTo("/account/login");
|
|
return;
|
|
}
|
|
|
|
var user = await UserManager.FindByIdAsync(userId);
|
|
if (user == null)
|
|
{
|
|
Snackbar.Add("User record not found.", Severity.Error);
|
|
Navigation.NavigateTo("/account/login");
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
var decodedCode = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
|
|
var result = await UserManager.ConfirmEmailAsync(user, decodedCode);
|
|
await Task.Delay(500);
|
|
if (result.Succeeded)
|
|
{
|
|
Snackbar.Add("Email verified successfully! You can now sign in.", Severity.Success);
|
|
}
|
|
else
|
|
{
|
|
Snackbar.Add("Verification failed. The link may have expired.", Severity.Error);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
Snackbar.Add("An error occurred during verification.", Severity.Error);
|
|
}
|
|
|
|
Navigation.NavigateTo("/account/login");
|
|
}
|
|
} |