Example #1
0
 /**
  * @Req\Route("/privilege/me/pick-profile")
  * @Req\Method({"GET"})
  *
  * @return JsonResponse
  */
 public function pickAction()
 {
     /** @var UsernamePasswordToken $token */
     $token = $this->tokenStorage->getToken();
     $uniqueness = $token->getUsername();
     $profile = $this->pickProfileApiWorker->pick($uniqueness);
     return new JsonResponse($profile);
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function refreshUser(SecurityUserInterface $user)
 {
     if (!$user instanceof User) {
         throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
     }
     $authenticationProfile = $this->pickAuthenticationProfileSharedWorker->pick($user->getUsername());
     $privilegeProfile = $this->pickPrivilegeProfileSharedWorker->pick($authenticationProfile['uniqueness']);
     return new User($user->getUsername(), $authenticationProfile['hash'], $authenticationProfile['salt'], $privilegeProfile['roles']);
 }
Example #3
0
 /**
  * Collects accounts.
  *
  * @return array An array of accounts with keys uniqueness, mobile, email
  *               and roles.
  */
 public function collect()
 {
     $uniquenesses = $this->collectUniquenessesSharedWorker->collect();
     $accounts = [];
     foreach ($uniquenesses as $uniqueness) {
         try {
             $mobileProfile = $this->pickMobileByNumberProfileApiWorker->pick($uniqueness['id']);
             $mobile = $mobileProfile['number'];
         } catch (NonExistentMobileUniquenessApiException $e) {
             $mobile = '';
         }
         try {
             $internetProfile = $this->pickInternetProfileApiWorker->pick($uniqueness['id']);
             $email = $internetProfile['email'];
         } catch (NonExistentInternetUniquenessApiException $e) {
             $email = '';
         }
         $privilegeProfile = $this->pickPrivilegeProfileApiWorker->pick($uniqueness['id']);
         $accounts[] = ['uniqueness' => $uniqueness['id'], 'mobile' => $mobile, 'email' => $email, 'roles' => $privilegeProfile['roles']];
     }
     return $accounts;
 }