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