当前位置: 首页>>代码示例>>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;未经允许,请勿转载。