Fix compatibility with Nextcloud 20

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-04-01 10:18:26 +02:00
parent 2747ad7fd2
commit 4430d2b497
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
2 changed files with 4 additions and 2 deletions

View File

@ -354,7 +354,8 @@ class RegistrationService {
$this->validateDisplayname($fullName);
}
if ($this->config->getAppValue('registration', 'show_phone', 'no') === 'yes') {
if (class_exists(PhoneNumberUtil::class)
&& $this->config->getAppValue('registration', 'show_phone', 'no') === 'yes') {
if ($phone) {
$this->validatePhoneNumber($phone);
} elseif ($this->config->getAppValue('registration', 'enforce_phone', 'no') === 'yes') {

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace OCA\Registration\Settings;
use libphonenumber\PhoneNumberUtil;
use OCA\Registration\AppInfo\Application;
use OCP\Accounts\IAccountManager;
use OCP\AppFramework\Http\TemplateResponse;
@ -109,7 +110,7 @@ class RegistrationSettings implements ISettings {
// FIXME Always true when Nextcloud 22 or 21.0.1 is minimum requirement
$this->initialState->provideInitialState(
'can_show_phone',
method_exists($this->accountManager, 'updateAccount')
method_exists($this->accountManager, 'updateAccount') && class_exists(PhoneNumberUtil::class)
);
$this->initialState->provideInitialState(
'show_phone',