コード例 #1
0
 public function execute($hasCode, $listener, $provider)
 {
     if (!$hasCode) {
         return $this->getAuthorization($provider);
     }
     $user = $this->users->findByUsernameOrCreate($this->getUser($provider));
     $this->auth->login($user, true);
     return $listener->userAuthenticated($user);
 }
コード例 #2
0
ファイル: AuthenticateUser.php プロジェクト: sjardim/GA-Exam
 public function execute($provider, $hasCode, AuthenticateUserListener $listener)
 {
     if (!$hasCode) {
         return $this->getAuthorizationFirst($provider);
     }
     $user = $this->users->findByUsernameOrCreate($provider, $this->getProviderUser($provider));
     $this->auth->login($user, true);
     return $listener->userHasLoggedIn($user);
 }
コード例 #3
0
 /**
  * @param boolean $hasCode
  * @param AuthenticateUserListener $listener
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function google($hasCode, AuthenticateUserListener $listener)
 {
     if (!$hasCode) {
         return $this->socialite->driver('google')->redirect();
     }
     $user = $this->users->findByUsernameOrCreate($this->socialite->driver('google')->user());
     $this->auth->login($user, true);
     return $listener->userHasLoggedIn($user);
 }
コード例 #4
0
 public function execute($hasCode, AuthenticateUserListener $listener)
 {
     if (!$hasCode) {
         return $this->getAuthorizationFirst();
     } else {
         $user = $this->users->findByUsernameOrCreate($this->getGithubUser());
         $this->guard->login($user, true);
         return $listener->userHasLoggedIn($user);
     }
 }
コード例 #5
0
 function it_creates_a_user_if_authorization_is_granted(Factory $socialite, UserRepository $repository, Guard $guard, User $user, AuthenticateUserListener $listener)
 {
     $socialite->driver('github')->willReturn(new ProviderStub());
     $repository->findByUsernameOrCreate(ProviderStub::$data)->willReturn($user);
     //        $guard->login($user, static::HAS_CODE)->shouldBeCalled();
     //        $listener->userHasLoggedIn($user)->shouldBeCalled();
     $this->execute(self::HAS_CODE, $listener);
 }
コード例 #6
0
 public function facebookCallback(\App\Repositories\UserRepository $listener)
 {
     $code = \Input::get('code');
     if (strlen($code) == 0) {
         return redirect('/login')->with('message', 'There was an error communicating with Facebook');
     }
     $facebook = new \Facebook(\Config::get('facebook'));
     $uid = $facebook->getUser();
     if ($uid == 0) {
         return redirect('/login')->with('message', 'There was an error');
     }
     $me = $facebook->api('/me');
     $user = $listener->findByUsernameOrCreate($me);
     \Auth::login($user);
     return redirect('/')->with('message', 'Logged in with Facebook');
 }