Exemple #1
0
 /**
  * @param UserInterface $user
  * @return bool
  */
 protected function isSecretLogin(UserInterface $user)
 {
     $result = false;
     $secretLoginRoleList = $this->collectionOptions->getLoginOptions()->getSecretLoginRoleList();
     if ($secretLoginRoleList && ($userRoles = $user->getRoles())) {
         $secretLoginRoleList = array_map('strtolower', $secretLoginRoleList);
         foreach ($userRoles as $userRole) {
             if (in_array(strtolower($userRole->getRoleId()), $secretLoginRoleList)) {
                 $code = $this->userCodeService->setCode4User($user, UserCodesEntity::TYPE_SECRET_LOGIN);
                 $this->mailService->secretLogin($user, $code);
                 $this->getFlashMessenger()->setNamespace($this::ERROR_NAME_SPACE)->addMessage('Please confirm your secret-login with your email');
                 $result = true;
             }
         }
     }
     return $result;
 }
Exemple #2
0
 /**
  * @param UserInterface $user
  * @param               $roleId
  * @return bool
  */
 protected function isRoleAlreadyAdded(UserInterface $user, $roleId)
 {
     $result = false;
     foreach ($user->getRoles() as $role) {
         if ($role->getId() == $roleId) {
             $result = true;
             break;
         }
     }
     return $result;
 }