Skip to content

Commit

Permalink
Update GroupRule.php
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchezzzhak authored Mar 24, 2023
1 parent b9203de commit 90bef7d
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions rules/GroupRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,12 @@ class GroupRule extends Rule implements IGroupRole
public function execute($user, $item, $params)
{
if (!Yii::$app->user->isGuest) {

/** @var \app\models\User $user */
$user = Yii::$app->user->identity;
$role = $user->role;

if ($item->name === self::ROLE_SUPER_ADMIN) {
return $role === $item->name;

} elseif ($item->name === self::ROLE_ADMIN) {
return $role === $item->name || $role === self::ROLE_SUPER_ADMIN;

}else if($item->name === self::ROLE_MANAGER){
return $role === $item->name
|| $role === self::ROLE_SUPER_ADMIN
|| $role === self::ROLE_USER
|| $role === self::ROLE_ADMIN;

} elseif ($item->name === self::ROLE_USER) {
return $role === $item->name
|| $role === self::ROLE_SUPER_ADMIN
|| $role === self::ROLE_ADMIN
|| $role === self::ROLE_MANAGER;
}
return ($role === $item->name);
}

return false;
}
}
}

0 comments on commit 90bef7d

Please sign in to comment.