Esempio n. 1
0
 public function loadUserByOpauthResult(OpauthResult $result)
 {
     $username = $result->getNickname();
     $user = UserQuery::create()->filterByKey($username)->findOneOrCreate();
     if ($user->isNew()) {
         $this->createUser($user, $result->getProvider() . ':' . $result->getUid() . ':' . $result->getNickname(), $result->getEmail(), $result->getName());
     }
     return $this->loadUserByUsername($username);
 }
Esempio n. 2
0
 public function __construct($username)
 {
     $user = UserQuery::create()->findOneByKey($username);
     if ($user == null) {
         throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
     }
     $this->username = $user->getKey();
     $this->firstname = $user->getFirstName();
     $this->lastname = $user->getLastName();
     $this->email = $user->getEmail();
     $this->enabled = $user->getActive();
     $this->accountNonExpired = true;
     $this->credentialsNonExpired = true;
     $this->accountNonLocked = true;
     $roles = array();
     foreach ($user->getGroups() as $group) {
         array_push($roles, $group->getName());
     }
     $this->roles = array_unique($roles);
 }