当前位置: 首页>>代码示例>>PHP>>正文


PHP Guard::loginUsingId方法代码示例

本文整理汇总了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;
 }
开发者ID:vjaykoogu,项目名称:smile-media-laravel,代码行数:35,代码来源:OAuth.php

示例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);
 }
开发者ID:kz,项目名称:timetable-pusher-backend,代码行数:16,代码来源:AuthenticateApiV1.php

示例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);
 }
开发者ID:ameliaikeda,项目名称:osu-web,代码行数:19,代码来源:AutologinFromLegacyCookie.php

示例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);
     }
 }
开发者ID:vitalysemenov,项目名称:oauth,代码行数:18,代码来源:UserConnected.php

示例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'));
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:22,代码来源:ResetPasswordController.php

示例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);
 }
开发者ID:valdinei,项目名称:rest,代码行数:30,代码来源:SessionController.php

示例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;
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:22,代码来源:ConfirmEmail.php


注:本文中的Illuminate\Contracts\Auth\Guard::loginUsingId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。