本文整理汇总了PHP中Illuminate\Contracts\Auth\Guard::loginUsingId方法的典型用法代码示例。如果您正苦于以下问题:PHP Guard::loginUsingId方法的具体用法?PHP Guard::loginUsingId怎么用?PHP Guard::loginUsingId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Auth\Guard
的用法示例。
在下文中一共展示了Guard::loginUsingId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* Autneticat
*
* @param $provider
* @return bool
*/
public function authenticate($provider)
{
$socialUser = $this->social->with($provider)->stateless()->user();
if (!$socialUser) {
return false;
}
$identity = $this->oauth->findByProviderNameAndId($socialUser->id, $provider);
if ($identity) {
$this->oauth->update($identity, ['token' => $socialUser->token]);
$this->auth->loginUsingId($identity->user_id, true);
return true;
}
$user = $this->user->findByEmail($socialUser->email);
if (!is_null($user)) {
$this->oauth->create(['provider_id' => $socialUser->id, 'provider' => $provider, 'user_id' => $user->id, 'token' => $socialUser->token]);
$this->user->update($user, ['status' => 1]);
$this->auth->login($user, true);
return true;
}
if (!setting('registration', true)) {
return false;
}
// Just create the user
$newUser = $this->user->create(['name' => $this->emailToName($socialUser->email), 'email' => $socialUser->email, 'password' => '', 'status' => 1, 'avatar' => $socialUser->avatar]);
event(new UserCreatedThroughOAuth($newUser));
$this->oauth->create(['provider_id' => $socialUser->id, 'provider' => $provider, 'user_id' => $newUser->id, 'token' => $socialUser->token]);
$this->auth->login($newUser, true);
return true;
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->user->authenticateApiV1($request->header('Authorization')) !== false) {
$this->auth->loginUsingId($this->user->authenticateApiV1($request->header('Authorization')));
} else {
return response('Invalid API token.', 401);
}
return $next($request);
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
$session = LegacySession::loadFromRequest($request);
if ($session !== null) {
$request->session()->flush();
$request->session()->regenerateToken();
$this->auth->loginUsingId($session->session_user_id, $session->session_autologin);
}
}
return $next($request);
}
示例4: handle
/**
* Handle user connected via social auth.
*
* @param \Orchestra\OAuth\User $model
* @param array $data
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function handle(Eloquent $model, array $data, Guard $auth)
{
if ($auth->check()) {
return;
}
if (!is_null($id = $this->getAuthenticatedUser($model))) {
$auth->loginUsingId($id, true);
}
}
示例5: update
/**
* @param $token
* @param TokenRepository $tokens
* @param ResetPasswordRequest $request
* @param Guard $guard
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update($token, TokenRepository $tokens, ResetPasswordRequest $request, Guard $guard)
{
$token = $tokens->findTokenByValue($token);
if ($token) {
$user = $this->dispatch(new ResetPassword($request->get('email'), $token, $request->get('password'), $request->get('password_confirmation')));
if ($user) {
$guard->loginUsingId($user->id);
return redirect('admin/start');
}
}
//always redirect to signin if we get here.
//the request was validated for correct input, so if the reset was no success,
//we simply bail out for security reasons.
return redirect()->to(store_route('store.auth.signin.index'))->withSuccess(Lang::get('users::front.request-handled'));
}
示例6: postLogin
/**
* Handle a login request to the application.
*
* @param AuthRequest $request
* @return \Illuminate\Http\Response
*/
public function postLogin(AuthRequest $request)
{
$throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return $this->respondThrottled($request);
}
if (!$this->auth->once($request->only('email', 'password'))) {
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return $this->respondLoginFail($request);
}
$user = $this->auth->getUser();
if (!$user->activated) {
$this->auth->logout();
return $this->respondNotActivated($request, $user->activation_code);
}
$this->auth->loginUsingId($user->id, $request->has('remember'));
if ($throttles) {
$this->clearLoginAttempts($request);
}
event('UserHasLoggedIn', [$this->auth->user()]);
return $this->respondLoginSuccess($request, $user);
}
示例7: handle
/**
* @param UserRepositoryInterface $users
* @param Guard $guard
* @return mixed
* @throws \Exception
*/
public function handle(UserRepositoryInterface $users, Guard $guard)
{
$user = $users->findUserByConfirmationToken($this->token->id);
if ($user) {
if (!$user->confirmed) {
$user->confirmed = 1;
}
//only reset the token if we actually found a user
$user->confirmation_token_id = null;
$user->save();
$guard->loginUsingId($user->id);
}
//token can always be deleted
$this->token->delete();
return $user;
}