public void UpdatePassword(User user) { using (var ctx = new ProjectCureContext()) { var dbUser = ctx.Users.FirstOrDefault(u => u.UserEmail == user.UserEmail); if (dbUser == null) { throw new ArgumentException(); } dbUser.UserPassword = SHA256Encryption.ComputeSHA256Hash(user.UserPassword); ctx.SaveChanges(); } }
public bool IsValidUser(string userName, string password) { using (var ctx = new ProjectCureContext()) { var user = ctx.Users.FirstOrDefault(u => u.UserEmail == userName && u.UserActiveIn); if (user == null) { return(false); } var hashedPassword = password == null ? null : SHA256Encryption.ComputeSHA256Hash(password); return(hashedPassword == user.UserPassword); } }