feat: started working on password reset and email confirmation, added columns to DB
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
e6b2c22bab
commit
828f784fc8
13 changed files with 179 additions and 13 deletions
|
@ -0,0 +1,6 @@
|
|||
@page "/sys/click/confirmmail/{userid}/{email}/{token}"
|
||||
<h3>Confirming your Email...</h3>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
@page "/sys/click/resetpw/{userid}/{hash}"
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using ImageBoardServerApp.Data.Repository
|
||||
@inject AuthenticationStateProvider authStateProvider
|
||||
@inject NavigationManager navManager
|
||||
<PageTitle>Password reset</PageTitle>
|
||||
<span>Password reset for account id #@userid</span>
|
||||
|
||||
<div class="login">
|
||||
<form>
|
||||
<RadzenFormField Text="New Password" Variant="Variant.Outlined">
|
||||
<RadzenPassword @bind-Value="@Password" />
|
||||
</RadzenFormField>
|
||||
<br/>
|
||||
<br/>
|
||||
<RadzenButton Click=@reset Text="reset" ButtonStyle="ButtonStyle.Secondary" />
|
||||
<br/>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
private string Password { get; set; }
|
||||
|
||||
[Parameter]
|
||||
[Required]
|
||||
public string userid { get; set; }
|
||||
|
||||
[Parameter]
|
||||
[Required]
|
||||
public string hash { get; set; }
|
||||
|
||||
public async void reset()
|
||||
{
|
||||
if (int.TryParse(userid, out _))
|
||||
return;
|
||||
var user = await UsersRepository.getUserByIdAsync(int.Parse(userid));
|
||||
if (user == null)
|
||||
return;
|
||||
if (user.ResetPasswordToken != hash)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Console.WriteLine("Resetting a password...");
|
||||
|
||||
user.Password = Password = BCrypt.Net.BCrypt.HashPassword(Password);
|
||||
|
||||
await UsersRepository.updateUserAsync(user);
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue