public function loginUser(Request $request)
 {
     $authenticatedUser = $this->googleAuthenticator->authenticateUser($request);
     try {
         $user = $this->googleAuthorizer->authorizeUser($authenticatedUser);
     } catch (FailureAuthorizedException $e) {
         if (!$this->googleRegisterManager->isUserAllowedToRegisterAutomatically($authenticatedUser)) {
             $this->logger->addAlert("User authorization failed ");
             throw new FailureAuthorizedException("XSolve Google Auth couldn't authorize user. User's domain is not allowed");
         }
         $this->googleRegisterManager->registerUser($authenticatedUser);
         $user = $authenticatedUser;
     } catch (NotAuthorizedException $e) {
         $this->logger->addInfo("User try to sign in");
         throw $e;
     }
     $user = $this->FOSUserLoginService->login($user);
     $this->logger->addInfo(sprintf("User %s singed in", $user->getUsername()));
     return $user;
 }
Esempio n. 2
0
 /**
  * Aplica y actualiza las reglas de la ACL
  *
  * @param $acl
  * @param $applyTo
  */
 private function applyAcl($acl, $applyTo)
 {
     $aclProviderCallable = $this->aclProviderCallable;
     if (isset($applyTo['users'])) {
         foreach ($applyTo['users'] as $username => $mask) {
             if ($user = $this->findUserByUsername($username)) {
                 $securityIdentity = UserSecurityIdentity::fromAccount($user);
                 $acl->insertObjectAce($securityIdentity, $this->getMask($mask));
             } else {
                 $this->logger->addAlert(sprintf('No es posible adicionar ACL para el usuario \'%s\', el mismo no pudo ser encontrado.', $username));
             }
         }
     }
     if (isset($applyTo['roles'])) {
         foreach ($applyTo['roles'] as $role => $mask) {
             $securityIdentity = new RoleSecurityIdentity($role);
             $acl->insertObjectAce($securityIdentity, $this->getMask($mask));
         }
     }
     $aclProviderCallable($acl, 'update');
 }