Commit 2fc8cb45 by Alexander Makarov

Fixes #4489: Fixed MySQL RBAC manager

parent c6569b1a
...@@ -345,7 +345,7 @@ class DbManager extends BaseManager ...@@ -345,7 +345,7 @@ class DbManager extends BaseManager
$query = (new Query)->select('b.*') $query = (new Query)->select('b.*')
->from(['a' => $this->assignmentTable, 'b' => $this->itemTable]) ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
->where('a.item_name=b.name') ->where('a.item_name=b.name')
->andWhere(['a.user_id' => $userId]); ->andWhere(['a.user_id' => (string)$userId]);
$roles = []; $roles = [];
foreach ($query->all($this->db) as $row) { foreach ($query->all($this->db) as $row) {
...@@ -383,7 +383,7 @@ class DbManager extends BaseManager ...@@ -383,7 +383,7 @@ class DbManager extends BaseManager
{ {
$query = (new Query)->select('item_name') $query = (new Query)->select('item_name')
->from($this->assignmentTable) ->from($this->assignmentTable)
->where(['user_id' => $userId]); ->where(['user_id' => (string)$userId]);
$childrenList = $this->getChildrenList(); $childrenList = $this->getChildrenList();
$result = []; $result = [];
...@@ -470,7 +470,7 @@ class DbManager extends BaseManager ...@@ -470,7 +470,7 @@ class DbManager extends BaseManager
public function getAssignment($roleName, $userId) public function getAssignment($roleName, $userId)
{ {
$row = (new Query)->from($this->assignmentTable) $row = (new Query)->from($this->assignmentTable)
->where(['user_id' => $userId, 'item_name' => $roleName]) ->where(['user_id' => (string)$userId, 'item_name' => $roleName])
->one($this->db); ->one($this->db);
if ($row === false) { if ($row === false) {
...@@ -491,7 +491,7 @@ class DbManager extends BaseManager ...@@ -491,7 +491,7 @@ class DbManager extends BaseManager
{ {
$query = (new Query) $query = (new Query)
->from($this->assignmentTable) ->from($this->assignmentTable)
->where(['user_id' => $userId]); ->where(['user_id' => (string)$userId]);
$assignments = []; $assignments = [];
foreach ($query->all($this->db) as $row) { foreach ($query->all($this->db) as $row) {
...@@ -614,7 +614,7 @@ class DbManager extends BaseManager ...@@ -614,7 +614,7 @@ class DbManager extends BaseManager
public function revoke($role, $userId) public function revoke($role, $userId)
{ {
return $this->db->createCommand() return $this->db->createCommand()
->delete($this->assignmentTable, ['user_id' => $userId, 'item_name' => $role->name]) ->delete($this->assignmentTable, ['user_id' => (string)$userId, 'item_name' => $role->name])
->execute() > 0; ->execute() > 0;
} }
...@@ -624,7 +624,7 @@ class DbManager extends BaseManager ...@@ -624,7 +624,7 @@ class DbManager extends BaseManager
public function revokeAll($userId) public function revokeAll($userId)
{ {
return $this->db->createCommand() return $this->db->createCommand()
->delete($this->assignmentTable, ['user_id' => $userId]) ->delete($this->assignmentTable, ['user_id' => (string)$userId])
->execute() > 0; ->execute() > 0;
} }
......
Markdown is supported
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