Пример #1
0
 /**
  * Register a new user using their Github account.
  *
  * @param string $code
  *
  * @return \App\User
  */
 public function register($userDetails)
 {
     $userDetails->email = $userDetails->getEmail();
     $profile = $this->profiles->findByUid($userDetails->getId());
     if (is_null($profile)) {
         $user = $this->users->findByEmail($userDetails->email);
         if (is_null($user)) {
             $user = $this->users->createFromGithubData($userDetails);
         }
         $profile = $this->profiles->createFromGithubData($userDetails, $user, $userDetails->token);
     } else {
         $profile = $this->profiles->updateToken($profile, $userDetails->token);
         $user = $profile->user;
     }
     return $user;
 }