Skip to content

Commit

Permalink
Added Base Permissions for all the users
Browse files Browse the repository at this point in the history
Config File now can be relocate to desired location to prevent config cache issue for closures
  • Loading branch information
vinodraut committed Dec 28, 2018
1 parent d35f83c commit 1550c3b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/YesAuthority.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,16 @@ class YesAuthority
function __construct()
{
$this->initialize();


// get permission info from config
$this->permissions = config('yes-authority');
// if file is stored somewhere else
$customConfigPath = array_get($this->permissions, 'custom_config_path');
if($customConfigPath) {
$this->permissions = require $customConfigPath;
}

$this->requestCheckStringId = '';
$this->isAccessIdsArray = false;
$this->userId = null;
Expand Down Expand Up @@ -161,6 +168,7 @@ protected function configure($requestForUserId = null, $options = [])
$this->configColRole = array_get($this->yesConfig, 'col_role');
$this->configColUserId = array_get($this->yesConfig, 'col_user_id');
$this->configColRoleId = array_get($this->yesConfig, 'col_role_id', $this->configColUserId);

$this->dependentsAccessIds = array_get($this->permissions, 'dependents');
$userModelString = array_get($this->yesConfig, 'user_model');
$userModelWhereClouses = array_get($this->yesConfig, 'user_model_where');
Expand Down Expand Up @@ -583,6 +591,16 @@ public function check($accessIdKey = null, $requestForUserId = null, array $opti
$this->accessStages[$accessIdKey] = [];
}

if(array_get($this->permissions, 'rules.base')) {
$isAccess = $this->performChecks($isAccess, $accessIdKey,
array_get($this->permissions, 'rules.base.allow'),
array_get($this->permissions, 'rules.base.deny'),
[
'check_level' => 'CONFIG_BASE'
]
);
}

if($this->performLevelChecks(1)) {
// check for permissions using roles
$isAccess = $this->performChecks($isAccess, $accessIdKey,
Expand Down Expand Up @@ -1506,6 +1524,7 @@ private function initialize() {

$this->checkLevel = 99;
$this->checkLevels = [
'CONFIG_BASE' => 0,
'CONFIG_ROLE' => 1, // Config Role
'CONFIG_USER' => 2, // Config User
'DB_ROLE' => 3, // DB Role
Expand Down

0 comments on commit 1550c3b

Please sign in to comment.