bulletboards/ImageBoardServerApp/Pages/Accounts/ClickOn/ClickOnConfirmEmail.razor
limited_dev 712ac3c020 fix: fixed issues with email confirmation
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
2023-06-13 19:59:21 +02:00

79 lines
No EOL
1.8 KiB
Text

@page "/sys/click/confirmmail/{userid}/{oldmail}/{proposedemail}/{token}"
@using System.ComponentModel.DataAnnotations
@using ImageBoardServerApp.Data.Repository
@inject NavigationManager navManager
<h3>Confirm your Email</h3>
<span>Confirmed email. Check Account Settings.</span>
@code {
private string msg { get; set; }
[Parameter]
[Required]
public string userid { get; set; }
[Parameter]
[Required]
public string proposedemail { get; set; }
[Parameter]
[Required]
public string oldmail { get; set; }
[Parameter]
[Required]
public string token { get; set; }
protected override async Task OnInitializedAsync()
{
if (!int.TryParse(userid, out _))
{
msg = "malformed userid.";
return;
}
var user = await UsersRepository.getUserByIdAsync(int.Parse(userid));
if (user.ConfirmedEmail)
return;
if (user == null)
{
msg = "Could not find user.";
return;
}
if (user.Email != oldmail)
{
msg = "This email is not specified to this account.";
return;
}
if (user.ProposedEmail != proposedemail)
{
msg = "This is not the specified new mail to this account.";
return;
}
if (user.ConfirmEmailToken != token)
{
msg = "This token is not associated with the specified account.";
return;
}
Console.WriteLine("");
user.ConfirmEmailToken = "-1";
user.ConfirmedEmail = true;
user.Email = proposedemail;
await UsersRepository.updateUserAsync(user);
msg = "The email has been confirmed.";
navManager.NavigateTo("/sys/click/red/_sys_logout");
}
}