!feat: removed the direct editing of passwords
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
22e9090057
commit
9c93f9d10c
1 changed files with 1 additions and 24 deletions
|
@ -16,9 +16,7 @@
|
|||
<input type="email" id="email" @bind="newMail" />
|
||||
<a @onclick="changeEmail" href="javascript:void(0)">[Change Email]</a>
|
||||
<br/>
|
||||
<span>Password: </span>
|
||||
<input type="password" id="password" @bind="newPassword" />
|
||||
<a @onclick="changePassword" href="javascript:void(0)">[Change Password]</a>
|
||||
<a href="/sys/resetpw">[Change Password]</a>
|
||||
<br/>
|
||||
<a href="/sys/logout">[Logout]</a>
|
||||
</Authorized>
|
||||
|
@ -32,7 +30,6 @@
|
|||
|
||||
private string mail { get; set; } = "";
|
||||
private string newMail { get; set; }
|
||||
private string newPassword { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
@ -63,24 +60,4 @@
|
|||
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
await UsersRepository.updateUserAsync(foundusr);
|
||||
}
|
||||
|
||||
private async Task changePassword()
|
||||
{
|
||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||
var usr = user.User;
|
||||
UserData foundusr = await UsersRepository.getUserByIdAsync(int.Parse(usr.Identity.Name));
|
||||
if (foundusr == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int userID = foundusr.UserID;
|
||||
if (newPassword == null || newPassword == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
foundusr.Password = BCrypt.Net.BCrypt.HashPassword(newPassword);
|
||||
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
await UsersRepository.updateUserAsync(foundusr);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue