Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #31 from landjea/master
Browse files Browse the repository at this point in the history
Reversed "no" and "all" access returns
  • Loading branch information
kaidesu committed Jan 29, 2016
2 parents 5be036d + baece82 commit 53ad482
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public function getPermissions()
*/
public function can($permission)
{
if ($this->special === 'all-access') {
return true;
}

if ($this->special === 'no-access') {
return false;
}

if ($this->special === 'all-access') {
return true;
}

$permissions = $this->getPermissions();

if (is_array($permission)) {
Expand All @@ -87,14 +87,14 @@ public function can($permission)
*/
public function canAtLeast(array $permission = array())
{
if ($this->special === 'all-access') {
return true;
}

if ($this->special === 'no-access') {
return false;
}

if ($this->special === 'all-access') {
return true;
}

$permissions = $this->getPermissions();

$intersection = array_intersect($permissions, $permission);
Expand Down
16 changes: 8 additions & 8 deletions src/Traits/ShinobiTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ public function can($permission, $arguments = [])
$can = false;

foreach ($this->roles as $role) {
if ($role->special === 'all-access') {
return true;
}

if ($role->special === 'no-access') {
return false;
}

if ($role->special === 'all-access') {
return true;
}

if ($role->can($permission)) {
$can = true;
}
Expand All @@ -162,14 +162,14 @@ public function canAtLeast(array $permissions)
$can = false;

foreach ($this->roles as $role) {
if ($role->special === 'all-access') {
return true;
}

if ($role->special === 'no-access') {
return false;
}

if ($role->special === 'all-access') {
return true;
}

if ($role->canAtLeast($permissions)) {
$can = true;
}
Expand Down

0 comments on commit 53ad482

Please sign in to comment.