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
 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();
 }