Skip to content

Commit

Permalink
fix command issue and fix permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
nahid committed Jan 15, 2018
1 parent fb02ea3 commit e458ac1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Commands/PermissionSyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function syncRolePermissions()
$permissions = [];
foreach ($permission as $rules) {
$rule = explode('.', $rules);
$perms = $permission_object->node($rule[0])->get(true);
$perms = $permission_object->node($rule[0])->get(false);
if ($rule[1] == '*') {
if (!is_null($perms)) {
if(!isset($permissions[$rule[0]])) {
Expand All @@ -95,7 +95,7 @@ protected function syncRolePermissions()
$permissions[$rule[0]] = [];
}

// dd($rule, $perms);
// dd($rule, $perms);

if (in_array($rule[1], $perms)) {
$permissions[$rule[0]][$rule[1]] = true;
Expand Down
15 changes: 7 additions & 8 deletions src/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function userAllows($user, $permission, $params = [])
}
}


if (is_string($permission)) {
if ($this->isPermissionDo($permission, $user, $params)) {
return true;
Expand Down Expand Up @@ -92,7 +91,6 @@ public function roleAllows($user, $permission, $params = [])
}
}


if (is_string($permission)) {
if ($this->isPermissionDo($permission, $user, $params)) {
return true;
Expand Down Expand Up @@ -131,15 +129,12 @@ public function allows($user, $permission, $params = [])
}
}


if (is_string($permission)) {
if ($this->isPermissionDo($permission, $user, $params)) {
return true;
}
}
}


}

throw new AuthorizationException('Unauthorized');
Expand Down Expand Up @@ -215,10 +210,14 @@ protected function callPolicy($callable, $params = [])
$arr_callable = explode('@', $callable);

if (count($arr_callable)>1) {
$class = new $arr_callable[0]();
$method = $arr_callable[1];
if (class_exists($arr_callable[0])) {
$class = new $arr_callable[0]();
$method = $arr_callable[1];

return call_user_func_array([$class, $method], $params);
if (method_exists($class, $method)) {
return call_user_func_array([$class, $method], $params);
}
}
}

return false;
Expand Down

0 comments on commit e458ac1

Please sign in to comment.