69 lines
2.5 KiB
Plaintext
69 lines
2.5 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>
|
|
|
|
<div class="confirm-container">
|
|
<div class="confirm-icon-wrapper">
|
|
<div class="confirm-icon-circle">
|
|
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"/></svg>
|
|
</div>
|
|
</div>
|
|
|
|
<h2 class="confirm-title">Verifying Your Account</h2>
|
|
<p class="confirm-desc">Please wait while we validate your email address...</p>
|
|
|
|
<MudProgressCircular Color="Color.Primary" Indeterminate="true" Size="Size.Large" />
|
|
</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");
|
|
}
|
|
} |