initial commit
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
@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 {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.confirm-icon-circle {
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
border-radius: 50%;
|
||||
background: #fff3ed;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.confirm-icon-circle svg {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
color: #f55b14;
|
||||
}
|
||||
.confirm-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.confirm-desc {
|
||||
font-size: 0.875rem;
|
||||
color: #64748b;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
</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>
|
||||
|
||||
<div class="confirm-title">Verifying Your Account</div>
|
||||
<div class="confirm-desc">Please wait while we validate your email address...</div>
|
||||
|
||||
<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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user