diff --git a/app/src/Controller/Component/RegistryAuthComponent.php b/app/src/Controller/Component/RegistryAuthComponent.php index 974fb3483..1054d3c13 100644 --- a/app/src/Controller/Component/RegistryAuthComponent.php +++ b/app/src/Controller/Component/RegistryAuthComponent.php @@ -588,11 +588,19 @@ public function getApplicationUserRoles(?int $coId): array { $appUserRoles['person_identifier'] = $this->getAuthenticatedUser(); if ($coId) { // Person ID - $appUserRoles['person_id'] = $this->getPersonID($coId) ?? null; - // Person Full Name - if (!empty($appUserRoles['person_id'])) { - $Names = TableRegistry::getTableLocator()->get('Names'); - $appUserRoles['person_fullname'] = $Names->primaryName((int)$appUserRoles['person_id'])->full_name; + $appUserRoles['person_id'] = null; + + try { + $appUserRoles['person_id'] = $this->getPersonID($coId); + + // Person Full Name + if (!empty($appUserRoles['person_id'])) { + $Names = TableRegistry::getTableLocator()->get('Names'); + $appUserRoles['person_fullname'] = $Names->primaryName((int)$appUserRoles['person_id'])->full_name; + } + } + catch(\Exception $e) { + // If there is no authenticated user getPersonID will throw an exception } }