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); }
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); }
/** * @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); }
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); } }
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); }
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'); }