diff --git a/ImageBoardServerApp/Pages/Accounts/ClickOn/ClickOnConfirmEmail.razor b/ImageBoardServerApp/Pages/Accounts/ClickOn/ClickOnConfirmEmail.razor
index 0fca738..5701993 100644
--- a/ImageBoardServerApp/Pages/Accounts/ClickOn/ClickOnConfirmEmail.razor
+++ b/ImageBoardServerApp/Pages/Accounts/ClickOn/ClickOnConfirmEmail.razor
@@ -1,49 +1,61 @@
-@page "/sys/click/confirmmail/{userid}/{email}/{token}"
+@page "/sys/click/confirmmail/{userid}/{oldmail}/{proposedemail}/{token}"
@using System.ComponentModel.DataAnnotations
@using ImageBoardServerApp.Data.Repository
Confirm your Email
-@msg
+Confirmed email. Check Account Settings.
@code {
- private string msg { get; set; } = "Loading...";
-
+ private string msg { get; set; }
+
[Parameter]
[Required]
public string userid { get; set; }
-
+
[Parameter]
[Required]
- public string email { get; set; }
-
+ public string proposedemail { get; set; }
+
+ [Parameter]
+ [Required]
+ public string oldmail { get; set; }
+
[Parameter]
[Required]
public string token { get; set; }
-
- protected override async Task OnParametersSetAsync()
- {
- await base.OnParametersSetAsync();
+ 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 != email)
+ 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.";
diff --git a/ImageBoardServerApp/Pages/Accounts/Register.razor b/ImageBoardServerApp/Pages/Accounts/Register.razor
index 3d0351f..d7b9ee2 100644
--- a/ImageBoardServerApp/Pages/Accounts/Register.razor
+++ b/ImageBoardServerApp/Pages/Accounts/Register.razor
@@ -61,9 +61,11 @@
return;
}
Console.WriteLine("Registering...");
+ var hash = TheManager.getmd5Hash();
UserData userToCreate = new UserData()
{
Email = Email,
+ ProposedEmail = Email,
Password = BCrypt.Net.BCrypt.HashPassword(Password),
Role = "User",
TimeBanned = -1,
@@ -71,7 +73,7 @@
BanReason = "Not banned",
ConfirmedEmail = false,
ResetPasswordExpiresAt = -1,
- ConfirmEmailToken = TheManager.getmd5Hash(),
+ ConfirmEmailToken = hash,
ResetPasswordToken = "-1"
};
if (await UsersRepository.getUserByEmailAsync(Email) != null)
@@ -80,9 +82,12 @@
return;
}
- await UsersRepository.createUserAsync(userToCreate);
+ int uid = await UsersRepository.createUserAsync(userToCreate);
- Postman.sendMail(Email, "Confirm Email", "");
+ Postman.sendMail(Email,
+ "Confirm email",
+ "Confirm you email:\n" +
+ $"https://bulletboards.xyz/sys/click/confirmmail/{uid}/{Email}/{Email}/{hash}");
var user = await UsersRepository.getUserByEmailRawAsync(Email);
if (user == null)
diff --git a/ImageBoardServerApp/Pages/Accounts/UserPage.razor b/ImageBoardServerApp/Pages/Accounts/UserPage.razor
index 2147f78..0d3f26a 100644
--- a/ImageBoardServerApp/Pages/Accounts/UserPage.razor
+++ b/ImageBoardServerApp/Pages/Accounts/UserPage.razor
@@ -1,6 +1,7 @@
@page "/sys/you"
@using ImageBoardServerApp.Auth
@using ImageBoardServerApp.Data.Repository
+@using ImageBoardServerApp.Util
@inject AuthenticationStateProvider authStateProvider
@inject NavigationManager navManager
@@ -12,6 +13,11 @@
Email: @userid
+ @if (isMailConfirmedMsg != null)
+ {
+ @isMailConfirmedMsg
+
+ }