本文整理汇总了PHP中App\Repositories\UserRepository::findByUsernameOrCreate方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRepository::findByUsernameOrCreate方法的具体用法?PHP UserRepository::findByUsernameOrCreate怎么用?PHP UserRepository::findByUsernameOrCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Repositories\UserRepository
的用法示例。
在下文中一共展示了UserRepository::findByUsernameOrCreate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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: execute
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: google
/**
* @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: execute
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: ProviderStub
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: facebookCallback
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');
}