Skip to content

Commit 38506fb

Browse files
committed
Library/AC: Optimize and Prevent getting account roles for guest player
1 parent b1df3cb commit 38506fb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

application/models/Acl_model.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public function __construct()
4141
*/
4242
public function getGroupRolesByUser(int $userId, false|string $moduleName = false): array
4343
{
44+
if ($userId == 0)
45+
return [];
46+
4447
$query = $this->db->table('acl_group_roles agr')
4548
->select('agr.role_name, agr.module')
4649
->join('acl_account_groups aag', 'aag.group_id = agr.group_id', 'inner')
@@ -116,6 +119,9 @@ public function getAccountRolesPermissions(int $userId = 0, int $default_group =
116119
*/
117120
public function getAccountPermissions(int $userId): array
118121
{
122+
if ($userId == 0)
123+
return [];
124+
119125
$query = $this->db->table('acl_account_permissions')->select("account_id, permission_name, module, value")->where("account_id", $userId)->get();
120126

121127
return $query->getResultArray() ?? [];
@@ -130,6 +136,9 @@ public function getAccountPermissions(int $userId): array
130136
*/
131137
public function getAccountRoles(int $userId, false|string $module = false): array
132138
{
139+
if ($userId == 0)
140+
return [];
141+
133142
$builder = $this->db->table('acl_account_roles')->select("role_name")->where("account_id", $userId);
134143

135144
if ($module) {
@@ -151,6 +160,9 @@ public function getGroupsByUser(false|int $accountId = false): array
151160
$accountId = $this->user->getId();
152161
}
153162

163+
if ($accountId == 0)
164+
return [];
165+
154166
$builder = $this->db->table("acl_account_groups aag, acl_groups ag");
155167
$builder->select("ag.id, ag.priority, ag.name, ag.color, ag.color");
156168
$builder->where("aag.account_id", $accountId);

0 commit comments

Comments
 (0)