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


PHP Auth::guest方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::guest()) {
         return redirect()->route('home');
     }
     return $next($request);
 }
开发者ID:synthx,项目名称:infuse,代码行数:14,代码来源:Logged.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::guest()) {
         \Session::flash('message', 'You are not allowed to be here. First Sign In!');
         redirect('/auth');
     }
 }
开发者ID:Asekahud,项目名称:Web_Programming,代码行数:14,代码来源:AuthMiddleware.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $uri_segments = $request->segments();
     if (!empty($uri_segments) && in_array("api", $uri_segments)) {
         return $next($request);
     }
     if (\Auth::guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('http://login.' . \Config::get('app.domain') . '/');
         }
     }
     $usuario = \Auth::user();
     if (!empty($usuario)) {
         //Menú de administrador
         if ($usuario->hasRole('administrador')) {
             \Menu::make('menu_lateral', function ($menu) {
                 $menu->add('Inicio', 'inicio');
             });
         }
     } else {
         \Redirect::to('/error500');
     }
     return $next($request);
 }
开发者ID:AndresRojasIsaza,项目名称:Delivery,代码行数:33,代码来源:UsersMidelware.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!\Auth::guest() && $request->user()->isBanned()) {
         return view('banned.ban');
     }
     return $next($request);
 }
开发者ID:AdrianKuriata,项目名称:projekt,代码行数:14,代码来源:BannedMiddleware.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->id('/login') && \Auth::guest()) {
         return redirect('/login');
     }
     return $next($request);
 }
开发者ID:allancarlos123,项目名称:estoque_laravel,代码行数:14,代码来源:AutorizacaoMiddleware.php

示例6: handle

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

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::guest()) {
         return redirect(route('auth.loginForm'));
     }
     return $next($request);
 }
开发者ID:ndrx-io,项目名称:elude,代码行数:15,代码来源:AuthMiddleware.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::guest()) {
         return redirect('home');
     }
     if (!$request->user()->isReferent()) {
         return redirect('home');
     }
     return $next($request);
 }
开发者ID:Kokanm,项目名称:eStudentLaravel,代码行数:17,代码来源:RedirectIfNotReferent.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::guest()) {
         return \Redirect::home();
     }
     if (Entrust::hasRole('admin') || Entrust::hasRole('superadmin') || Entrust::hasRole('leader')) {
         return $next($request);
     }
     return \Redirect::home();
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:17,代码来源:EntrustRoles.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::guest("admin")) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('systems/login');
         }
     }
     return $next($request);
 }
开发者ID:dangquanglight,项目名称:light-love-story,代码行数:18,代码来源:AdminAuthenticate.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 = null)
 {
     if (\Auth::guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         }
         // put the intended url into session for return upon login
         session()->put('url.intended', url());
         return redirect()->route('admin.login');
     }
     return $next($request);
 }
开发者ID:andycrockett,项目名称:andycrockett,代码行数:21,代码来源:Authenticate.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::guest()) {
     } else {
         if (!\Request::ajax()) {
             $menus = \Auth::user()->generateMenu();
             view()->share(['mainMenu' => $menus]);
         }
     }
     view()->share(['title' => config('app.title'), 'instansi' => config('app.instansi')]);
     return $next($request);
 }
开发者ID:htwibowo,项目名称:simonev,代码行数:19,代码来源:Bootstrapper.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->is('admin') or $request->is('admin/*')) {
         if (\Auth::guest()) {
             return redirect('/')->with('flash_info', 'У вас нет прав доступа.');
         }
         if (!is_admin_role(\Auth::user())) {
             return redirect('/')->with('flash_info', 'У вас нет прав доступа.');
         }
     }
     return $next($request);
 }
开发者ID:Ravend6,项目名称:laravel_base_v5.2,代码行数:19,代码来源:Admin.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             flash()->error("PLEASE_LOGIN");
             return redirect()->guest('auth/login');
         }
     }
     if (!$request->is('dashboard') && !$request->is('/')) {
         $page = $request->path();
         $myCredentials = session('myCredentials');
         $flag = true;
         foreach ($myCredentials as $credential_group) {
             foreach ($credential_group as $credential) {
                 $credential_path = $credential['path'];
                 if (strpos($page, $credential_path) == 0) {
                     $reg_edit = "~^(?:{$credential_path}/(\\d+)/edit)\$~x";
                     $reg_create = "~^(?:{$credential_path}/create)\$~x";
                     $myPermissions = session('myPermissions');
                     if (preg_match($reg_edit, $page) || preg_match($reg_create, $page)) {
                         if ($myPermissions[$credential_path]['write'] == 1) {
                             $flag = false;
                             break 2;
                         }
                     } else {
                         $flag = false;
                         break 2;
                     }
                     if ($request->isMethod('post')) {
                         if ($myPermissions[$credential_path]['write'] == 1) {
                             $flag = false;
                             break 2;
                         }
                     }
                 }
             }
         }
         if ($flag) {
             //Lang::get('general.NO_PERMISSION', ['page' => $page]);
             flash()->error("You do not have permission to access {$page}.");
             return redirect()->intended('dashboard');
         }
     }
     //\Session::regenerateToken();
     return $next($request);
 }
开发者ID:nstojanovickg,项目名称:diplomski,代码行数:55,代码来源:AuthMiddleware.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     \Me::setOnline();
     if (\Auth::check()) {
         $access = \Menu::access()['return'];
         if ($access == false) {
             return redirect('/');
         }
         if (!empty(\Session::get('lock')) && \Request::path() != 'lockscreen') {
             return redirect('/lockscreen');
         }
     }
     if (\Auth::guest()) {
         if (!empty(\Session::get('lock'))) {
             \Session::forget('lock');
         }
     }
     return $next($request);
 }
开发者ID:pedangkayu,项目名称:rsos-git,代码行数:26,代码来源:AksesPageMiddleware.php


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