當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Middleware\Auth類代碼示例

本文整理匯總了PHP中App\Http\Middleware\Auth的典型用法代碼示例。如果您正苦於以下問題:PHP Auth類的具體用法?PHP Auth怎麽用?PHP Auth使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Auth類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $role)
 {
     if (!\Auth::user()->{$role}) {
         return \App::abort(401, 'You are not allowed to access this resource.');
     }
     return $next($request);
 }
開發者ID:halidovz,項目名稱:restful,代碼行數:14,代碼來源:CheckRoleMiddleware.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $role)
 {
     if (\Auth::user()->can($role . '-access')) {
         return $next($request);
     }
     return response('Unauthorized.', 401);
 }
開發者ID:rawaludin,項目名稱:approcket-preproject,代碼行數:14,代碼來源:Role.php

示例3: userStatte

 public static function userStatte()
 {
     $state = true;
     if (\Auth::User() == null) {
         $state = false;
     }
 }
開發者ID:pumba3211,項目名稱:PHP,代碼行數:7,代碼來源:usernotnull.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request Request Object
  * @param \Closure                 $next    Closure Object
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!\Auth::user()->hasRole('admin')) {
         return response('Unauthorized.', 401);
     }
     return $next($request);
 }
開發者ID:Nishaanthan,項目名稱:mcq,代碼行數:15,代碼來源:Admin.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->connections()->where('connection_id', '=', $request->segment(3))->count() == 0) {
         return $next($request);
     }
     return redirect()->back()->withErrors(['Already Connected', 'You can not connect with this person cause the connection already exists.']);
 }
開發者ID:RyOberfelder,項目名稱:ccard,代碼行數:14,代碼來源:ConnectMiddleware.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::user()->nivelAccess == 1) {
         return redirect('/mbl');
     }
     return $next($request);
 }
開發者ID:DurvalNascimento,項目名稱:desconsolidacao,代碼行數:14,代碼來源:agentes.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::check('admin')) {
         return redirect('/systems');
     }
     return $next($request);
 }
開發者ID:dangquanglight,項目名稱:light-love-story,代碼行數:14,代碼來源:AdminGuest.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $roleName)
 {
     if (Auth::check() && !Auth::user()->hasRole($roleName)) {
         return abort(401, 'Unauthorized');
     }
     return $next($request);
 }
開發者ID:muhamadanjar,項目名稱:SIMTARU,代碼行數:14,代碼來源:LevelMiddleware.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::check() && \Auth::user()->isAdmin())) {
         return redirect('/')->withErrors('Access denied to ADMIN functionality!');
     }
     return $next($request);
 }
開發者ID:Pheonick,項目名稱:whatsnext,代碼行數:14,代碼來源:admin.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::user()->ref_user_level_id != 3) {
         return response('akses ditolak', 401);
     }
     return $next($request);
 }
開發者ID:r3k4,項目名稱:ujianonline,代碼行數:14,代碼來源:siswaAkses.php

示例11: handle

 public function handle($request, Closure $next)
 {
     if (\Auth::check() && \Auth::user()->isNotChild() && \Auth::user()->isActive()) {
         return $next($request);
     }
     return redirect('home');
 }
開發者ID:bradsmithcan,項目名稱:laravel_infusionsoft_constantcontact,代碼行數:7,代碼來源:NotChild.php

示例12: 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

示例13: 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

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!in_array(\Auth::user()->user_type, config('squash.club+member'))) {
         return redirect('notifications/club-notices');
     }
     return $next($request);
 }
開發者ID:rakeshmistrynz,項目名稱:squashapp,代碼行數:14,代碼來源:RedirectIfNotAdministrator.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!(\Auth::check() && !\Auth::user()->isBanned())) {
         return redirect('banned')->withErrors('User is banned.');
     }
     return $next($request);
 }
開發者ID:Pheonick,項目名稱:whatsnext,代碼行數:14,代碼來源:notbanned.php


注:本文中的App\Http\Middleware\Auth類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。