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


PHP ACL::permits方法代码示例

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


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

示例1: testPermissionsCanBeSetForRoutes

 public function testPermissionsCanBeSetForRoutes()
 {
     $user = $this->createUserWithRoles();
     \ACL::setUser($user);
     $controller = Mockery::mock('\\ApiController');
     $controller->shouldReceive('tests')->once()->andReturn(\Response::json(['success' => 'great']));
     $controller->shouldReceive('getActionPermissions')->once()->andReturn(['tests' => 'job.apply']);
     \Route::enableFilters();
     \Route::filter('test.permissions.filter', function ($route) {
         require 'app/acl.php';
         $permissions = $route->getAction()['uses'][0]->getActionPermissions();
         $perm = $permissions[$route->getAction()['uses'][1]];
         $this->assertTrue(ACL::permits('job.apply', $route->parameters()));
     });
     \Route::get('/test/perms/{id}', [$controller, 'tests'])->after('test.permissions.filter');
     $this->call('GET', '/test/perms/3');
     $this->assertResponseOk();
 }
开发者ID:nilove,项目名称:motibubackend,代码行数:18,代码来源:PermissionsTest.php

示例2: explode

        return;
    }
    $closure = explode('@', \Route::currentRouteAction());
    $controllerClass = $closure[0];
    $controllerMethod = $closure[1];
    $permissionsDefinitionClass = 'Motibu\\Permitters\\Definitions\\' . $controllerClass . 'Permissions';
    if (class_exists($permissionsDefinitionClass)) {
        $permissionsMap = (new $permissionsDefinitionClass())->getPermissions();
        // no permissions needed for action
        if (!isset($permissionsMap[$controllerMethod])) {
            return;
        }
        $permissions = $permissionsMap[$controllerMethod];
        $permits = true;
        foreach ($permissions as $permission) {
            $permits = $permits && ACL::permits($permission, $route->parameters());
        }
        if (!$permits) {
            \App::abort(403, 'Unauthorized action.');
        }
    }
});
// Allow cross origin requests
\Route::filter('allow_cross_origin', function ($route, $request, $response) {
    $response->header('Access-Control-Allow-Origin', '*');
});
\Route::filter('oauth.add_auth_header', function ($route, $request) {
    $headers = getallheaders();
    if (isset($headers['Authorization'])) {
        $request->headers->set('Authorization', $headers['Authorization']);
    }
开发者ID:nilove,项目名称:motibubackend,代码行数:31,代码来源:filters.php


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