Commit 215b429c authored by Quentin Ribac's avatar Quentin Ribac
Browse files

FEAT #17436 TIME 0:08 canGivePrivilege works without parameters field

parent 1dfcfcb0
......@@ -17,6 +17,7 @@ namespace Group\controllers;
use SrcCore\models\ValidatorModel;
use User\models\UserGroupModel;
use Group\models\GroupPrivilegeModel;
use PHPUnit\Util\Xml\Validator;
class PrivilegeController
{
......@@ -81,11 +82,14 @@ class PrivilegeController
public static function canGivePrivilege(array $args)
{
ValidatorModel::notEmpty($args, ['userId', 'groupId', 'privilegeId', 'parameters']);
ValidatorModel::notEmpty($args, ['userId', 'groupId', 'privilegeId']);
ValidatorModel::intVal($args, ['userId', 'groupId']);
ValidatorModel::stringType($args, ['privilegeId']);
if ($args['privilegeId'] == 'manage_users') {
if (!isset($args['parameters']['authorized'])) {
return false;
}
if (!PrivilegeController::hasPrivilege(['userId' => $args['userId'], 'privilege' => 'manage_users'])) {
return false;
} elseif (PrivilegeController::hasPrivilege(['userId' => $args['userId'], 'privilege' => 'manage_groups'])) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment