From 82bf3a74c1f75ec2c311a7a0b830b900d09da2bd Mon Sep 17 00:00:00 2001 From: iglocska Date: Wed, 28 Jun 2023 14:59:31 +0200 Subject: [PATCH] chg: [internal] fetch first role if no default is set --- src/Controller/UsersController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php index 95db80a..d33490c 100644 --- a/src/Controller/UsersController.php +++ b/src/Controller/UsersController.php @@ -75,6 +75,9 @@ class UsersController extends AppController $validRoles = $this->Users->Roles->find('list')->order(['name' => 'asc'])->all()->toArray(); } $defaultRole = $this->Users->Roles->find()->select(['id'])->where(['is_default' => true])->first()->toArray(); + if (empty($defaultRole)) { + $defaultRole = $this->Users->Roles->find()->select(['id'])->first()->toArray(); + } $individuals = $this->Users->Individuals->find('list', $individuals_params)->toArray(); $this->CRUD->add([ 'beforeMarshal' => function($data) {