コード例 #1
0
 public function process(WebhookEvent $event)
 {
     $data = $event->getData();
     if (!isset($data['user_id'])) {
         return null;
     }
     $user = $this->userRepository->find($data['user_id']);
     return ['event' => $event->getName(), 'user' => ['id' => $user->getId(), 'email' => $user->getEmail(), 'login' => $user->getLogin()], 'granted' => $data['granted'], 'rejected' => $data['rejected']];
 }
コード例 #2
0
ファイル: BaseVoter.php プロジェクト: luisbrito/Phraseanet
 public function vote(TokenInterface $token, $object, array $attributes)
 {
     if (!$object || !$this->supportsClass(get_class($object))) {
         return self::ACCESS_ABSTAIN;
     }
     $user = ctype_digit($token->getUser()) ? $this->userRepository->find((int) $token->getUser()) : null;
     foreach ($attributes as $attribute) {
         $attribute = strtolower($attribute);
         if ($this->supportsAttribute($attribute)) {
             $isGranted = call_user_func([$this, 'isGranted'], $attribute, $object, $user);
             return $isGranted ? self::ACCESS_GRANTED : self::ACCESS_DENIED;
         }
     }
     return self::ACCESS_ABSTAIN;
 }
コード例 #3
0
 /**
  * @param $login
  * @param bool $notifyUser
  * @return string
  * @throws InvalidArgumentException
  */
 public function requestPasswordResetTokenByLogin($login, $notifyUser = true)
 {
     $user = $this->userRepository->findByLogin($login);
     if (!$user) {
         throw new InvalidArgumentException('phraseanet::erreur: Le compte n\'a pas ete trouve');
     }
     return $this->requestPasswordResetTokenByUser($user, $notifyUser);
 }
コード例 #4
0
 /**
  * @param $authorizedCollections
  * @param $user
  * @return mixed
  * @throws \Exception
  */
 private function applyAclsToUser(array $authorizedCollections, User $user)
 {
     $acl = $this->aclProvider->get($user);
     if ($this->configuration->get(['registry', 'registration', 'auto-register-enabled'])) {
         $template_user = $this->userRepository->findByLogin(User::USER_AUTOREGISTER);
         $acl->apply_model($template_user, array_keys($authorizedCollections));
     }
 }
コード例 #5
0
 /**
  * @param string $login
  * @return User
  */
 private function getUserOrCurrentUser($login = null)
 {
     if ($login !== null) {
         $user = $this->userRepository->findByLogin($login);
         if (!$user) {
             throw new AccountException('User not found');
         }
     } else {
         $user = $this->authenticationService->getUser();
     }
     return $user;
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function getUsrId($username, $password, Request $request)
 {
     if (null === ($user = $this->repository->findRealUserByLogin($username))) {
         return null;
     }
     if ($user->isSpecial()) {
         return null;
     }
     // check locked account
     if ($user->isMailLocked()) {
         throw new AccountLockedException('The account is locked', $user->getId());
     }
     if (false === $user->isSaltedPassword()) {
         // we need a quick update and continue
         if ($this->oldEncoder->isPasswordValid($user->getPassword(), $password, $user->getNonce())) {
             $this->userManipulator->setPassword($user, $password);
         }
     }
     if (false === $this->encoder->isPasswordValid($user->getPassword(), $password, $user->getNonce())) {
         return null;
     }
     return $user->getId();
 }