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


PHP Auth::guard方法代码示例

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


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

示例1: login

 /**
  * Handle a login request to the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function login(Request $request)
 {
     $loginusername = $this->loginUsername();
     $this->validate($request, [$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);
     $possiblecolumns = $this->loginColumns();
     $templogin = $credentials[$loginusername];
     unset($credentials[$loginusername]);
     foreach ($possiblecolumns as $column) {
         $credentials[$column] = $templogin;
         if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {
             return $this->handleUserWasAuthenticated($request, $throttles);
         }
         unset($credentials[$column]);
     }
     // 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 $this->sendFailedLoginResponse($request);
 }
开发者ID:molteber,项目名称:puz-multicolumnauth,代码行数:36,代码来源:AuthenticatesUsers.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check() && !$request->is("register")) {
         return redirect('/');
     }
     return $next($request);
 }
开发者ID:guyjstitt,项目名称:RJL-Redux,代码行数:15,代码来源:RedirectIfAuthenticated.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     // Check for the guard and redirect accordingly
     if (Auth::guard($guard)->guest()) {
         if ($request->ajax() || $request->wantsJson()) {
             return response('Unauthorized.', 401);
         } elseif ($guard == 'student') {
             return redirect()->guest('/students/login');
         } elseif ($guard == 'teacher') {
             return redirect()->guest('/teachers/login');
         } elseif ($guard == 'hostelStaff') {
             return redirect()->guest('/hostelStaffs/login');
         } elseif ($guard == 'libraryStaff') {
             return redirect()->guest('/libraryStaffs/login');
         } elseif ($guard == 'departmentStaff') {
             return redirect()->guest('/departmentStaffs/login');
         } elseif ($guard == 'chiefWardenStaff') {
             return redirect()->guest('/chiefWardenStaffs/login');
         } elseif ($guard == 'adminStaff') {
             return redirect()->guest('/adminStaffs/login');
         } elseif ($guard == 'admin') {
             return redirect()->guest('/admins/login');
         }
     }
     return $next($request);
 }
开发者ID:prateekprshr-nith,项目名称:beautifulCode,代码行数:34,代码来源:Authenticate.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (!Auth::check() || !Auth::guard($guard)->user()->admin) {
         return redirect('/');
     }
     return $next($request);
 }
开发者ID:Necrotex,项目名称:lootsheet,代码行数:14,代码来源:Administrator.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         null;
     }
     return $next($request);
 }
开发者ID:arywidiantara,项目名称:Tugas,代码行数:15,代码来源:RedirectIfAuthenticated.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return abort(401, "The user is already logged");
     }
     return $next($request);
 }
开发者ID:Techraav,项目名称:n2i,代码行数:15,代码来源:RedirectIfAuthenticated.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->guest()) {
         $this->killDeadCookies($request);
     }
     return $next($request);
 }
开发者ID:bhutanio,项目名称:laravel-utilities,代码行数:14,代码来源:RemoveStaleCookies.php

示例8: myAccountOrderList

 public function myAccountOrderList()
 {
     $user = Auth::guard('web')->user();
     $orders = Order::where('user_id', '=', $user->id)->get();
     $view = view('order.my-account-order-list')->with('orders', $orders);
     return $view;
 }
开发者ID:mage2,项目名称:laravel-ecommerce,代码行数:7,代码来源:OrderController.php

示例9: getLogout

 /**
  * Logout manager.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getLogout()
 {
     Auth::guard($this->guard)->logout();
     flash()->success(trans('messages.logout.title'), trans('messages.logout.content'));
     event('manager.logged_out');
     return redirect(route('admin.login'));
 }
开发者ID:BlazOrazem,项目名称:laravel-basis,代码行数:12,代码来源:AuthController.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @param Guard                     $guard
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next, Guard $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect(route('home_path'));
     }
     return $next($request);
 }
开发者ID:ahk-ch,项目名称:chamb.net,代码行数:16,代码来源:RedirectIfAuthenticatedAhk.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  * @param string|null              $guard
  *
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = 'admin')
 {
     if (Auth::guard($guard)->check()) {
         return redirect('/admin');
     }
     return $next($request);
 }
开发者ID:mage2,项目名称:laravel-ecommerce,代码行数:16,代码来源:RedirectIfAdminAuthenticated.php

示例12: getLogin

 public function getLogin(Request $request)
 {
     //Check Remember
     if (Auth::guard('admin')->viaRemember()) {
         return redirect('/');
     }
     //Check Login
     if (Auth::guard('admin')->check()) {
         return redirect('/');
     }
     //Do login
     if ($request->method() == 'POST') {
         $data = $request->only('email', 'password', 'remember');
         if ($data['remember'] == 'remember_me') {
             $this->remember = true;
         }
         $attempt = Auth::guard('admin')->attempt(['email' => $data['email'], 'password' => $data['password']], $this->remember);
         if ($attempt) {
             return redirect('/');
         } else {
             $request->session()->flash('Errors', 'Email or password is wrong');
             return redirect()->back()->withInput();
         }
     }
     return view('backend/login/index')->with(['title' => $this->title]);
 }
开发者ID:haster312,项目名称:laravel_rikkei,代码行数:26,代码来源:AuthController.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (!Auth::guard($guard)->guest()) {
         return redirect(route('admin:index'));
     }
     return $next($request);
 }
开发者ID:Golars,项目名称:Naissance_Laravel,代码行数:15,代码来源:AdminAuth.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect()->intended('/home');
     }
     return $next($request);
 }
开发者ID:dfinkdd,项目名称:MakerNation,代码行数:15,代码来源:RedirectIfAuthenticated.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (!Auth::guard('admin')->check()) {
         return "hata !";
     }
     //return $next($request);
 }
开发者ID:berkcekisbas,项目名称:belirtileri,代码行数:15,代码来源:Admin.php


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