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


PHP Auth::user方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request. User must be logged in to do admin check
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->is_admin == 1) {
         return $next($request);
     }
     return redirect()->guest('/');
 }
开发者ID:johnevano,项目名称:laraveltest,代码行数:14,代码来源:AdminMiddleware.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::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

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

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->salesman_yn == 'Y') {
         return $next($request);
     }
     return redirect('/');
 }
开发者ID:comsi02,项目名称:ordermart,代码行数:14,代码来源:AuthenticateWithSalesman.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()->nivelAccess == 1) {
         return redirect('/mbl');
     }
     return $next($request);
 }
开发者ID:DurvalNascimento,项目名称:desconsolidacao,代码行数:14,代码来源:agentes.php

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

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->isSudo()) {
         return $next($request);
     }
     return redirect('/');
 }
开发者ID:sparkan,项目名称:Sparkous,代码行数:14,代码来源:VerifySudo.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::user()->role != 'admin') {
         return "This page for only ADMIN!";
     }
     return $next($request);
 }
开发者ID:hunguetit,项目名称:Laravel-Ex,代码行数:14,代码来源:RoleMiddleware.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $siteID = $request->route('sites');
     $site = \App\Models\Site::find($siteID);
     // normal and admin users accessing other site info
     if (\Auth::user()->super == "No") {
         if (\Auth::user()->site_id != $siteID) {
             if ($request->ajax()) {
                 return response('Unauthorized', 401);
             } else {
                 return redirect()->guest('noAccess');
             }
         }
     }
     // if super user is trying to access a site belonging to another company
     if (\Auth::user()->super == "Yes") {
         if (\Auth::user()->site->company_id != $site->company_id) {
             if ($request->ajax()) {
                 return response('Unauthorized', 401);
             } else {
                 return redirect()->guest('noAccess');
             }
         }
     }
     return $next($request);
 }
开发者ID:leanne-abarro,项目名称:tagAndTrack,代码行数:33,代码来源:SiteFilter.php

示例10: handle

 /**
  * filtre pour protéger les étudiants de prendre certaines routes
  * Note: pourrait probablement être remplacé par un système comme Sentry, mais ca fait la job pour l'instant. 
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->type != 'p') {
         return redirect('/home');
     }
     return $next($request);
 }
开发者ID:BenoitDesrosiers,项目名称:GestionNoteEtudiant51,代码行数:15,代码来源:ProfSeulement.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Auth::user()->can('can_view_dashboard')) {
         return response('Unauthorized.', 401);
     }
     return $next($request);
 }
开发者ID:jdelise,项目名称:career_site,代码行数:14,代码来源:CanViewAdminDash.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check() && \Auth::user()->isActive()) {
         return redirect('./home');
     }
     return $next($request);
 }
开发者ID:bradsmithcan,项目名称:laravel_infusionsoft_constantcontact,代码行数:14,代码来源:RedirectIfAuthenticated.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::user()->level() < 4) {
         abort(403, "¡Usted no tiene los permisos para ingresar a este proceso.");
     }
     return $next($request);
 }
开发者ID:jumaya,项目名称:redbpim,代码行数:14,代码来源:isAdmin.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::user()->team_id) {
         return redirect()->action('TeamsController@show');
     }
     return $next($request);
 }
开发者ID:axsauze,项目名称:SDHacks,代码行数:14,代码来源:RedirectIfTeamExists.php

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


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