Beispiel #1
0
 /**
  * @param BaseUser $user
  * @return User
  */
 public static function fromUser(BaseUser $user)
 {
     $newUser = new User();
     $newUser->setUsername($user->getUsername());
     $newUser->setEmail($user->getEmail());
     $newUser->setActive($user->isActive());
     $newUser->setDisplayName($user->getDisplayName());
     $newUser->setFirstName($user->getFirstName());
     $newUser->setLastName($user->getLastName());
     return $newUser;
 }
 /**
  * @param string $username The username
  *
  * @return UserInterface
  *
  * @see UsernameNotFoundException
  *
  * @throws UsernameNotFoundException if the user is not found
  *
  */
 public function loadUserByUsername($username)
 {
     $sessionKey = 'seiffert_crowd_auth.user';
     if ($this->session->has($sessionKey)) {
         return $this->session->get($sessionKey);
     }
     try {
         $user = User::fromUser($this->crowd->getUser($username));
         $this->session->set($sessionKey, $user);
         return $user;
     } catch (UserNotFoundException $e) {
         throw new UsernameNotFoundException($e->getMessage(), $e->getCode(), $e);
     }
 }