Skip to content

Commit b8c22ec

Browse files
committed
Fix issue with roles
1 parent 784875b commit b8c22ec

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/Api/Controllers/RolesController.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,28 @@ public function onConstruct()
3535
$this->model = new Roles();
3636

3737
//get the list of roes for the systems + my company
38+
$companyTotalRoles = Roles::count([
39+
'conditions' => 'apps_id = :apps_id: AND companies_id = :companies_id:',
40+
'bind' => [
41+
'apps_id' => $this->acl->getApp()->getId(),
42+
'companies_id' => $this->userData->currentCompanyId(),
43+
]
44+
]);
45+
3846
$this->additionalSearchFields = [
3947
['is_deleted', ':', '0'],
40-
['apps_id', ':', Apps::CANVAS_DEFAULT_APP_ID . '|' . $this->acl->getApp()->getId()],
41-
['companies_id', ':', '1|' . $this->userData->currentCompanyId()],
48+
['apps_id', ':', $this->acl->getApp()->getId()],
49+
['companies_id', ':', $this->userData->currentCompanyId()],
4250
];
51+
52+
if ($companyTotalRoles === 0) {
53+
$this->additionalSearchFields = [
54+
['is_deleted', ':', '0'],
55+
['apps_id', ':', Apps::CANVAS_DEFAULT_APP_ID],
56+
['companies_id', ':', 1],
57+
['is_default', ':', 1],
58+
];
59+
}
4360
}
4461

4562
/**

0 commit comments

Comments
 (0)