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

Reversed "no" and "all" access returns #31

Merged
merged 2 commits into from
Jan 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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