private bool ValidateCredentials(string password, Guid userId) { var user = UserRepository.GetById(userId); if (string.IsNullOrEmpty(user?.PasswordHash)) { return(false); } var hashPassword = HashCryptographyHelper.GetSaltPassword(HashCryptographyHelper.GetSha512Hash(password), user.Salt); return(hashPassword.Equals(user.PasswordHash)); }
//private IBaseItemRepository BaseItemRepository { get; } //private IGroupToUserRepository GroupToUserRepository { get; } //private IGroupRepository GroupRepository { get; } //private ITokenHelper TokenHelper { get; } RegistrationResultModel IAuthHelper.RegistrationUser(RegistrationRequestModel <SiteAuthModel> model) { var salt = HashCryptographyHelper.GetSalt(); var userModel = new UserModel { Email = model.Data.Email, PasswordHash = !string.IsNullOrEmpty(model.Data.Password) ? HashCryptographyHelper.GetSaltPassword( HashCryptographyHelper.GetSha512Hash(model.Data.Password), salt ) : null, Salt = salt }; return(Registration(userModel, true, model.Groups)); }