You are here

public function CasProtectedUserFieldConstraintValidator::validate in CAS 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Validation/Constraint/CasProtectedUserFieldConstraintValidator.php \Drupal\cas\Plugin\Validation\Constraint\CasProtectedUserFieldConstraintValidator::validate()

Overrides ProtectedUserFieldConstraintValidator::validate

File

src/Plugin/Validation/Constraint/CasProtectedUserFieldConstraintValidator.php, line 65

Class

CasProtectedUserFieldConstraintValidator
Decorates the ProtectedUserFieldConstraint constraint.

Namespace

Drupal\cas\Plugin\Validation\Constraint

Code

public function validate($items, Constraint $constraint) {

  // Skip the validator if CAS is configured with restricted password
  // management and if the user being validated is a CAS user.
  if (!empty($items)) {
    $account = $items
      ->getEntity();
    if ($account && $this->restrictedPasswordManagement && !empty($this->casUserManager
      ->getCasUsernameForAccount($account
      ->id()))) {
      return;
    }
  }
  parent::validate($items, $constraint);
}