public bool CheckOldPassword(string oldPassword, int userId) { var unitOfWork = new UnitOfWork(new OasisContext()); var userPasswordHash = unitOfWork.GetBaseRepository <User>().Get(userId).PasswordHash; return(HashPasswordHelper.VerifyHashedPassword(userPasswordHash, oldPassword)); }
public bool IsPasswordNew(string newPassword, int userId) { var unitOfWork = new UnitOfWork(new OasisContext()); var userPasswords = unitOfWork.GetBaseRepository <UserPassword>().GetAll(); return(userPasswords.All(userPassword => !HashPasswordHelper.VerifyHashedPassword(userPassword.PasswordHash, newPassword))); }
public bool VerifyCredentials(string userName, string password) { var unitOfWork = new UnitOfWork(new OasisContext()); var user = unitOfWork.GetBaseRepository <User>() .GetAll(r => r.UserRoles) .SingleOrDefault(r => r.UserName == userName); return(user != null && HashPasswordHelper.VerifyHashedPassword(user.PasswordHash, password)); }