From 9b2adba6aa40caadbb30d212978eb03ec0b45140 Mon Sep 17 00:00:00 2001 From: Pellaeon Lin Date: Sat, 4 Aug 2018 15:48:33 +0800 Subject: [PATCH] Fix# registrationservice: handle case where group to be added does not exist --- service/registrationservice.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/service/registrationservice.php b/service/registrationservice.php index 7715dd2..475a039 100644 --- a/service/registrationservice.php +++ b/service/registrationservice.php @@ -294,12 +294,15 @@ class RegistrationService { // Add user to group $registered_user_group = $this->config->getAppValue($this->appName, 'registered_user_group', 'none'); if ( $registered_user_group !== 'none' ) { - try { - $group = $this->groupManager->get($registered_user_group); + $group = $this->groupManager->get($registered_user_group); + if ( $group === null ) { + // This might happen if $registered_user_group is deleted after setting the value + // Here I choose to log error instead of stopping the user to register + $this->logger->error("You specified newly registered users be added to '$registered_user_group' group, but it does not exist."); + $groupId = ''; + } else { $group->addUser($user); $groupId = $group->getGID(); - } catch (\Exception $e) { - throw new RegistrationException($e->getMessage()); } } else { $groupId = "";