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