當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。