Skip to content

Commit

Permalink
Refactor new code
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Jul 12, 2022
1 parent 61b2fd1 commit e69eb05
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/AuthTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public function restrictToGroups($groups, $uri = null)
* the user to the URI set in $url or the site root, and attempt
* to set a status message.
*
* @param $permissions
* @param string $uri The URI to redirect to on fail.
* @param int|int[]|string|string[] $permissions
* @param string $uri The URI to redirect to on fail.
*
* @throws RedirectException
*
Expand All @@ -127,23 +127,13 @@ public function restrictWithPermissions($permissions, $uri = null)
{
$this->setupAuthClasses();

if ($this->authenticate->check())
{
if (is_array($permissions))
{
foreach ($permissions as $permission)
{
if ($this->authorize->hasPermission($permission, $this->authenticate->id())
{
return true;
}
}

if ($this->authenticate->check()) {
if (! is_array($permissions)) {
$permissions = [$permissions];
}
else
{
if ($this->authorize->hasPermission($permissions, $this->authenticate->id() ) )
{

foreach ($permissions as $permission) {
if ($this->authorize->hasPermission($permission, $this->authenticate->id())) {
return true;
}
}
Expand Down

0 comments on commit e69eb05

Please sign in to comment.