@page "/sys/resetpw"
@using ImageBoardServerApp.Data.Repository
@using ImageBoardServerApp.Util
Reset your Password
@if (msg != null)
{
@msg
}
@code {
private string Email { get; set; }
private string msg { get; set; }
private async void resetPassword()
{
msg = "Checking...";
var user = await UsersRepository.getUserByEmailRawAsync(Email);
if (user == null)
{
msg = "This user is not registered.";
return;
}
Console.WriteLine("Resetting a password...");
msg = "Generating";
var hash = TheManager.getmd5Hash();
user.ResetPasswordToken = hash;
user.ResetPasswordExpiresAt = DateTimeOffset.Now.ToUnixTimeMilliseconds() + 300000;
await UsersRepository.updateUserAsync(user);
msg = "Sending...";
Postman.sendMail(user.Email,
"Password Reset",
"Reset your Password using this link:\n" +
$"https://bulletboards.xyz/sys/click/resetpw/{user.UserID}/{hash}");
msg = "A reset email has been sent to the selected email, if that email is registered here. The link expires in 5 Minutes";
}
}