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


PHP Auth::getLastAttempted方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Auth::getLastAttempted方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::getLastAttempted方法的具体用法?PHP Auth::getLastAttempted怎么用?PHP Auth::getLastAttempted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Auth的用法示例。


在下文中一共展示了Auth::getLastAttempted方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleUserWasAuthenticated

 /**
  * Send the response after the user was authenticated.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  bool  $throttles
  * @return \Illuminate\Http\Response
  */
 protected function handleUserWasAuthenticated(Request $request, $throttles)
 {
     if ($throttles) {
         $this->clearLoginAttempts($request);
     }
     // if (method_exists($this, 'authenticated')) {
     //     return $this->authenticated($request, Auth::user());
     // }
     $user = Auth::getLastAttempted();
     $previous_session = $user->session_id;
     if ($previous_session) {
         \Session::getHandler()->destroy($previous_session);
         Auth::setUser($user);
         Auth::logout();
     }
     Auth::login($user, $request->has('remember'));
     $user->session_id = \Session::getId();
     $user->save();
     return redirect()->intended($this->redirectPath());
 }
开发者ID:jzengg,项目名称:LaravelApp,代码行数:27,代码来源:AuthenticatesUsers.php

示例2: login

 public function login(Request $request)
 {
     $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     // If the class is using the ThrottlesLogins trait, we can automatically throttle
     // the login attempts for this application. We'll key this by the username and
     // the IP address of the client making these requests into this application.
     $throttles = $this->isUsingThrottlesLoginsTrait();
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     $credentials = $this->getCredentials($request);
     //  if (Auth::attempt($credentials, $request->has('remember'))) {
     //      $this->swapUserSession(Auth::user());
     //      return $this->handleUserWasAuthenticated($request, $throttles);
     //  }
     if (Auth::validate($credentials)) {
         $user = Auth::getLastAttempted();
         $previous_session = $user->last_session_id;
         if ($previous_session) {
             \Session::getHandler()->destroy($previous_session);
             Auth::setUser($user);
             Auth::logout();
         }
         Auth::login($user, $request->has('remember'));
         $user->last_session_id = \Session::getId();
         $user->save();
         return redirect()->intended($this->redirectPath());
     }
     // If the login attempt was unsuccessful we will increment the number of attempts
     // to login and redirect the user back to the login form. Of course, when this
     // user surpasses their maximum number of attempts they will get locked out.
     if ($throttles) {
         $this->incrementLoginAttempts($request);
     }
     return redirect()->back()->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
 }
开发者ID:WillLiang918,项目名称:patient_database,代码行数:36,代码来源:AuthController.php

示例3: postLogin

 public function postLogin(Request $request)
 {
     $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     // If the class is using the ThrottlesLogins trait, we can automatically throttle
     // the login attempts for this application. We'll key this by the username and
     // the IP address of the client making these requests into this application.
     $throttles = $this->isUsingThrottlesLoginsTrait();
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     $credentials = $this->getCredentials($request);
     $remember = $request->has('remember');
     if (Auth::attempt($credentials, $remember, false)) {
         $user = Auth::getLastAttempted();
         if ((int) $user->active === 1) {
             Auth::login($user, $remember);
             return $this->handleUserWasAuthenticated($request, $throttles);
         }
     }
     // If the login attempt was unsuccessful we will increment the number of attempts
     // to login and redirect the user back to the login form. Of course, when this
     // user surpasses their maximum number of attempts they will get locked out.
     if ($throttles) {
         $this->incrementLoginAttempts($request);
     }
     return redirect($this->loginPath())->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
 }
开发者ID:angebe,项目名称:CloudWac.github.io,代码行数:27,代码来源:AuthController.php


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