• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Middleware\Auth类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Auth类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


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


示例17: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!\Auth::check('volunteer')) {
         return redirect('/volunteer');
     }
     return $next($request);
 }
开发者ID:gospelslide,项目名称:cry_final,代码行数:14,代码来源:VolunteerGuest.php


示例18: handle

 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $route = \Route::getCurrentRoute();
     // $route->uri(), $request->path()
     $roles = \Auth::user()->roles;
     $allow = true;
     try {
         // Check if route has permission
         foreach ($roles as $role) {
             foreach ($role->permissions as $permission) {
                 $allow = $allow & !$this->denied($request, $route, $permission);
             }
         }
     } catch (\Exception $e) {
         \Log::error($e->getFile() . ':' . $e->getLine() . ' ' . $e->getMessage());
         $allow = false;
     }
     // Apply access
     \Log::info('ACCESS:' . \Auth::user()->name . ':' . $request->method() . ':' . $request->path() . ':' . ($allow ? 'ALLOWED' : 'DENIED'));
     if (!$allow) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return response(view('admin/unauthorized'), 401);
         }
     } else {
         return $next($request);
     }
 }
开发者ID:bdgeek,项目名称:laraproto,代码行数:36,代码来源:BackofficePermission.php


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


示例20: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->hak_akses == 1) {
         return $next($request);
     }
     return redirect(\URL::to('error'));
 }
开发者ID:blacknvcone,项目名称:eAgenda,代码行数:14,代码来源:CEOMiddleware.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Requests\ArticleRequest类代码示例发布时间:2022-05-23
下一篇:
PHP Auth\Auth类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap