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


PHP Sentry::hasAccess方法代碼示例

本文整理匯總了PHP中Sentry::hasAccess方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sentry::hasAccess方法的具體用法?PHP Sentry::hasAccess怎麽用?PHP Sentry::hasAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sentry的用法示例。


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (!\Sentry::check() || !\Sentry::hasAccess('superuser')) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->route('account.login');
         }
     }
     return $next($request);
 }
開發者ID:rafaelvieiras,項目名稱:connect,代碼行數:18,代碼來源:Superuser.php

示例2: switch

        switch ($rule) {
            case 'index':
            case 'show':
                $userRule = $module . '.view';
                break;
            case 'create':
            case 'store':
                $userRule = $module . '.create';
                break;
            case 'edit':
            case 'update':
                $userRule = $module . '.update';
                break;
            case 'destroy':
                $userRule = $module . '.delete';
                break;
            default:
                $userRule = Route::currentRouteName();
                break;
        }
    }
    // no access to the request page and request page not the root admin page
    if (!Sentry::hasAccess($userRule) and $userRule !== 'admin.view') {
        return Redirect::to('admin')->with('error', Lang::get('backend::permissions.access_denied'));
    } else {
        if (!Sentry::hasAccess($userRule) and $userRule === 'admin.view') {
            //can't see the admin home page go back to home site page
            return Redirect::to('/')->with('error', Lang::get('backend::permissions.access_denied'));
        }
    }
});
開發者ID:hanyitom,項目名稱:laravel-backend,代碼行數:31,代碼來源:routes.php

示例3: downloadtemplate

 public function downloadtemplate($data)
 {
     $file = public_path() . '/uploads/templates/' . $data;
     if (file_exists($file)) {
         return Response::download($file);
     } else {
         if (Sentry::hasAccess('admin')) {
             return Redirect::route('admin.template.index')->with("errorMessage", "Maaf file tidak ada.");
         } else {
             if (Sentry::hasAccess('kepala')) {
                 return Redirect::route('admin.template.index')->with("errorMessage", "Maaf file tidak ada.");
             } else {
                 if (Sentry::hasAccess('kasubbag')) {
                     return Redirect::route('kasubbag.template.index')->with("errorMessage", "Maaf file tidak ada.");
                 }
             }
         }
     }
 }
開發者ID:inseo201,項目名稱:simkinerja,代碼行數:19,代碼來源:TemplatesController.php

示例4: switch

        switch ($rule) {
            case 'index':
            case 'show':
                $userRule = $module . '.view';
                break;
            case 'create':
            case 'store':
                $userRule = $module . '.create';
                break;
            case 'edit':
            case 'update':
                $userRule = $module . '.update';
                break;
            case 'destroy':
                $userRule = $module . '.delete';
                break;
            default:
                $userRule = Route::currentRouteName();
                break;
        }
    }
    // no access to the request page and request page not the root admin page
    if (!Sentry::hasAccess($userRule) and $userRule !== 'cpanel.view') {
        return Redirect::route('cpanel.home')->with('error', Lang::get('cpanel::permissions.access_denied'));
    } else {
        if (!Sentry::hasAccess($userRule) and $userRule === 'cpanel.view') {
            //can't see the admin home page go back to home site page
            return Redirect::to('/')->with('error', Lang::get('cpanel::permissions.access_denied'));
        }
    }
});
開發者ID:stevemo,項目名稱:cpanel,代碼行數:31,代碼來源:routes.php


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