2023-06-08 21:34:59 +00:00
|
|
|
@page "/sys/click/confirmmail/{userid}/{email}/{token}"
|
2023-06-09 07:45:14 +00:00
|
|
|
@using System.ComponentModel.DataAnnotations
|
|
|
|
@using ImageBoardServerApp.Data.Repository
|
|
|
|
<h3>Confirm your Email</h3>
|
|
|
|
|
|
|
|
<span>@msg</span>
|
2023-06-08 21:34:59 +00:00
|
|
|
|
|
|
|
@code {
|
2023-06-09 07:45:14 +00:00
|
|
|
private string msg { get; set; } = "Loading...";
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public string userid { get; set; }
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public string email { get; set; }
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public string token { get; set; }
|
2023-06-08 21:34:59 +00:00
|
|
|
|
2023-06-09 07:45:14 +00:00
|
|
|
protected override async Task OnParametersSetAsync()
|
|
|
|
{
|
|
|
|
await base.OnParametersSetAsync();
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
var user = await UsersRepository.getUserByIdAsync(int.Parse(userid));
|
|
|
|
|
|
|
|
if (user == null)
|
|
|
|
{
|
|
|
|
msg = "Could not find user.";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (user.Email != email)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-12 10:34:35 +00:00
|
|
|
user.ConfirmEmailToken = "-1";
|
2023-06-09 07:45:14 +00:00
|
|
|
user.ConfirmedEmail = true;
|
|
|
|
|
|
|
|
await UsersRepository.updateUserAsync(user);
|
|
|
|
|
|
|
|
msg = "The email has been confirmed.";
|
|
|
|
}
|
|
|
|
|
2023-06-08 21:34:59 +00:00
|
|
|
}
|