initial commit
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
@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 ===== */
|
||||
.confirm-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.confirm-icon-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.confirm-icon-circle {
|
||||
width: 4.5rem;
|
||||
height: 4.5rem;
|
||||
border-radius: 50%;
|
||||
background: rgba(139, 92, 246, 0.1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.confirm-icon-circle svg {
|
||||
width: 2.25rem;
|
||||
height: 2.25rem;
|
||||
color: #8B5CF6;
|
||||
}
|
||||
|
||||
.confirm-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #1E293B;
|
||||
margin: 0 0 0.25rem 0;
|
||||
}
|
||||
|
||||
.confirm-desc {
|
||||
font-size: 0.875rem;
|
||||
color: #64748B;
|
||||
margin: 0 0 2rem 0;
|
||||
}
|
||||
|
||||
/* ===== SPINNER ===== */
|
||||
.confirm-spinner {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
border: 4px solid rgba(139, 92, 246, 0.15);
|
||||
border-top-color: #8B5CF6;
|
||||
border-radius: 50%;
|
||||
animation: confirm-spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@@keyframes confirm-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
||||
|
||||
<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="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>
|
||||
</div>
|
||||
|
||||
<h2 class="confirm-title">Verifying Your Account</h2>
|
||||
<p class="confirm-desc">Please wait while we validate your email address...</p>
|
||||
|
||||
<div class="confirm-spinner"></div>
|
||||
</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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user