本文整理匯總了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');
}