public function execute($hasCode, AuthenticateUserListener $listener)
 {
     if (!$hasCode) {
         return $this->getAuthorizationFirst();
     }
     $user = $this->users->findByUsernameOrCreate($this->getGithubUser());
     $this->auth->login($user, true);
     return $listener->userHasLoggedIn($user);
 }
Esempio n. 2
0
 /**
  * @param boolean $hasCode
  * @param AuthenticateUserListener $listener
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function execute($hasCode, $provider, AuthenticateUserListener $listener)
 {
     $this->provider = $provider;
     if (!$hasCode) {
         return $this->getAuthorizationFirst();
     }
     $result = $this->getSocialUser();
     if ($result['success']) {
         $user = $this->users->findByUsernameOrCreate($result['user'], $this->provider);
         $this->auth->login($user, true);
         return $listener->userHasLoggedIn($user);
     } else {
         return $listener->userLoggedInFailed($result);
     }
 }
 /**
  * @param boolean $hasCode
  * @param AuthenticateUserListener $listener
  * @param $type
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function execute($hasCode, AuthenticateUserListener $listener, $type)
 {
     if (!$hasCode) {
         return $this->getAuthorizationFirst();
     }
     $linkedInData = $this->getLinkedinUser();
     $user = $this->users->findOrCreate($linkedInData, $type);
     $this->auth->login($user, true);
     $user->authType = 'linkedin';
     $user->save();
     if (is_null($user->profile)) {
         $name = explode(' ', $linkedInData->name);
         $profile = new Profile(['first_name' => head($name), 'last_name' => last($name)]);
         $user->profile()->save($profile);
     }
     return $listener->userHasLoggedIn($user);
 }