コード例 #1
0
 /**
  * @param AppscoToken $token
  * @throws \RuntimeException
  * @return \Symfony\Component\Security\Core\User\UserInterface
  */
 protected function getUser(AppscoToken $token)
 {
     try {
         $user = $this->userProvider->loadUserByUsername($token->getAccount()->getEmail());
     } catch (UsernameNotFoundException $ex) {
         $user = $this->createUser($token);
     }
     if (false == $user instanceof UserInterface) {
         throw new \RuntimeException('User provider did not return an implementation of user interface.');
     }
     return $user;
 }
コード例 #2
0
 /**
  * @param AppscoToken $token
  * @param Request $request
  */
 protected function setLocale(AppscoToken $token, Request $request)
 {
     $locale = 'en';
     $user = $token->getAccount();
     if ($user) {
         $l = $user->getLocale();
         if ($l) {
             $locale = $l;
         }
     }
     $request->getSession()->set('_locale', $locale);
     $request->setLocale($locale);
 }
コード例 #3
0
 /**
  * @param \Appsco\Dashboard\ApiBundle\Security\Core\Authentication\Token\AppscoToken $token
  *
  * @return UserInterface
  */
 public function create(AppscoToken $token)
 {
     return new Account($token->getUsername(), $this->store->load($token->getUsername()));
 }