limited_dev
e8e97b2cd9
!fix: The user auth system now uses the id, not the email Signed-off-by: limited_dev <loginakkisativ@gmail.com>
61 lines
No EOL
1.3 KiB
Text
61 lines
No EOL
1.3 KiB
Text
@page "/sys/click/confirmmail/{userid}/{email}/{token}"
|
|
@using System.ComponentModel.DataAnnotations
|
|
@using ImageBoardServerApp.Data.Repository
|
|
<h3>Confirm your Email</h3>
|
|
|
|
<span>@msg</span>
|
|
|
|
@code {
|
|
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; }
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await base.OnParametersSetAsync();
|
|
|
|
if (!int.TryParse(userid, out _))
|
|
{
|
|
msg = "This is not a valid id.";
|
|
return;
|
|
}
|
|
|
|
var user = await UsersRepository.getUserByIdAsync(int.Parse(userid));
|
|
|
|
if (user == null)
|
|
{
|
|
msg = "Could not find user.";
|
|
return;
|
|
}
|
|
|
|
if (user.Email != email)
|
|
{
|
|
msg = "The email does not match.";
|
|
return;
|
|
}
|
|
|
|
if (user.ConfirmEmailToken != token)
|
|
{
|
|
msg = "The token is not correct.";
|
|
return;
|
|
}
|
|
|
|
user.ConfirmEmailToken = "0";
|
|
user.ConfirmedEmail = true;
|
|
|
|
await UsersRepository.updateUserAsync(user);
|
|
|
|
msg = "The email has been confirmed.";
|
|
}
|
|
|
|
} |