Exemplo n.º 1
0
 /**
  * Adds new roles from CAS server since last authentication if some was added in CAS-Server.
  * Is used only if Account was persisted. See persistAccount() method.
  *
  * @param string  $providerName Provider name. WARNING: not in settings set useStaticProviderNameByPersistingAccounts.
  * @param Account $account
  *
  * @return void
  *
  * @todo : move persistAll() at shutdown
  */
 private function updateRolesInAccount($providerName, Account &$account)
 {
     $casAttributes = $this->casManager->getCasAttributes($providerName);
     $casServerRoles = $this->getRoles($providerName, $casAttributes);
     $accountMustBeUpdated = false;
     foreach ($casServerRoles as $casServerRole) {
         $accountMustBeUpdated = $accountMustBeUpdated == true ? $accountMustBeUpdated : !$account->hasRole($casServerRole);
         $account->addRole($casServerRole);
     }
     if ($accountMustBeUpdated) {
         $this->accountRepository->update($account);
     }
     $this->persistenceManager->persistAll();
 }