Доп проверки
This commit is contained in:
parent
ddcdef0aed
commit
626759b0c5
@ -138,14 +138,14 @@ namespace DatabaseCore
|
|||||||
{
|
{
|
||||||
var passwordHash = GetPasswordHash(password);
|
var passwordHash = GetPasswordHash(password);
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
var user = context.Users.FirstOrDefault(x => x.UserName == login && x.PasswordHash == passwordHash);
|
var user = context.Users.FirstOrDefault(x => x.UserName == login && x.PasswordHash == passwordHash && !x.IsDeleted);
|
||||||
await CheckUserAsync(login, user, context);
|
await CheckUserAsync(login, user, context);
|
||||||
user.DateLastVisit = DateTime.Now;
|
user.DateLastVisit = DateTime.Now;
|
||||||
user.CountAttempt = 0;
|
user.CountAttempt = 0;
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
User = user.Id;
|
User = user.Id;
|
||||||
Roles = context.UserRoles.Where(x => x.UserId == user.Id).Select(x => x.RoleId).ToList();
|
Roles = context.UserRoles.Where(x => x.UserId == user.Id && !x.IsDeleted).Select(x => x.RoleId).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task LogoutAsync()
|
public async Task LogoutAsync()
|
||||||
@ -160,7 +160,7 @@ namespace DatabaseCore
|
|||||||
public async Task ChangePassword(string login, string oldPassword, string newPassword)
|
public async Task ChangePassword(string login, string oldPassword, string newPassword)
|
||||||
{
|
{
|
||||||
using var context = DatabaseManager.GetContext;
|
using var context = DatabaseManager.GetContext;
|
||||||
var user = context.Users.FirstOrDefault(x => x.UserName == login && x.PasswordHash == GetPasswordHash(oldPassword));
|
var user = context.Users.FirstOrDefault(x => x.UserName == login && x.PasswordHash == GetPasswordHash(oldPassword) && !x.IsDeleted);
|
||||||
await CheckUserAsync(login, user, context);
|
await CheckUserAsync(login, user, context);
|
||||||
user.PasswordHash = GetPasswordHash(newPassword);
|
user.PasswordHash = GetPasswordHash(newPassword);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
@ -184,7 +184,7 @@ namespace DatabaseCore
|
|||||||
{
|
{
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
user = context.Users.FirstOrDefault(x => x.UserName == login);
|
user = context.Users.FirstOrDefault(x => x.UserName == login && !x.IsDeleted);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
user.CountAttempt++;
|
user.CountAttempt++;
|
||||||
|
Loading…
Reference in New Issue
Block a user