From 626759b0c56405f54a6e2c0a61a8100f381072c4 Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Sun, 28 Mar 2021 10:52:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=BF=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DepartmentPortal/Common/DatabaseCore/SecurityManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs b/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs index 8eb4076..a3cf4ac 100644 --- a/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs +++ b/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs @@ -138,14 +138,14 @@ namespace DatabaseCore { var passwordHash = GetPasswordHash(password); 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); user.DateLastVisit = DateTime.Now; user.CountAttempt = 0; await context.SaveChangesAsync(); 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() @@ -160,7 +160,7 @@ namespace DatabaseCore public async Task ChangePassword(string login, string oldPassword, string newPassword) { 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); user.PasswordHash = GetPasswordHash(newPassword); await context.SaveChangesAsync(); @@ -184,7 +184,7 @@ namespace DatabaseCore { if (user == null) { - user = context.Users.FirstOrDefault(x => x.UserName == login); + user = context.Users.FirstOrDefault(x => x.UserName == login && !x.IsDeleted); if (user != null) { user.CountAttempt++;