Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/registration.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-04-01 10:16:51 +0300
committerJoas Schilling <coding@schilljs.com>2021-04-01 10:26:22 +0300
commit8ef7b52c19594c16b986db94adb69693830f5d1d (patch)
tree5b8249b94e511bb6f1794cd9a212460f64146dd1 /lib
parentd34e6c20de332b01a9fb0308287e63fc24f04d34 (diff)
Add new admin settings to show/enforce fullname/phone
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/RegisterController.php4
-rw-r--r--lib/Controller/SettingsController.php8
-rw-r--r--lib/Service/RegistrationService.php19
-rw-r--r--lib/Settings/RegistrationSettings.php29
4 files changed, 43 insertions, 17 deletions
diff --git a/lib/Controller/RegisterController.php b/lib/Controller/RegisterController.php
index 45d1f32..bf7e9fe 100644
--- a/lib/Controller/RegisterController.php
+++ b/lib/Controller/RegisterController.php
@@ -234,9 +234,9 @@ class RegisterController extends Controller {
'email_is_login' => $this->config->getAppValue('registration', 'email_is_login', 'no') === 'yes',
'loginname' => $loginname,
'fullname' => $fullname,
- 'show_fullname' => $this->config->getAppValue('registration', 'enfore_fullname', 'no') === 'yes',
+ 'show_fullname' => $this->config->getAppValue('registration', 'show_fullname', 'no') === 'yes',
'phone' => $phone,
- 'show_phone' => $this->config->getAppValue('registration', 'enfore_phone', 'no') === 'yes',
+ 'show_phone' => $this->config->getAppValue('registration', 'show_phone', 'no') === 'yes',
'message' => $message,
'password' => $password,
'additional_hint' => $additional_hint,
diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php
index 66ab814..33ae0f0 100644
--- a/lib/Controller/SettingsController.php
+++ b/lib/Controller/SettingsController.php
@@ -61,6 +61,10 @@ class SettingsController extends Controller {
string $username_policy_regex,
?bool $admin_approval_required,
?bool $email_is_login,
+ ?bool $show_fullname,
+ ?bool $enforce_fullname,
+ ?bool $show_phone,
+ ?bool $enforce_phone,
?bool $domains_is_blocklist,
?bool $show_domains,
?bool $disable_email_verification) {
@@ -101,6 +105,10 @@ class SettingsController extends Controller {
$this->config->setAppValue($this->appName, 'admin_approval_required', $admin_approval_required ? 'yes' : 'no');
$this->config->setAppValue($this->appName, 'email_is_login', $email_is_login ? 'yes' : 'no');
+ $this->config->setAppValue($this->appName, 'show_fullname', $show_fullname ? 'yes' : 'no');
+ $this->config->setAppValue($this->appName, 'enforce_fullname', $enforce_fullname ? 'yes' : 'no');
+ $this->config->setAppValue($this->appName, 'show_phone', $show_phone ? 'yes' : 'no');
+ $this->config->setAppValue($this->appName, 'enforce_phone', $enforce_phone ? 'yes' : 'no');
$this->config->setAppValue($this->appName, 'domains_is_blocklist', $domains_is_blocklist ? 'yes' : 'no');
$this->config->setAppValue($this->appName, 'show_domains', $show_domains ? 'yes' : 'no');
$this->config->setAppValue($this->appName, 'disable_email_verification', $disable_email_verification ? 'yes' : 'no');
diff --git a/lib/Service/RegistrationService.php b/lib/Service/RegistrationService.php
index f453a23..3831dec 100644
--- a/lib/Service/RegistrationService.php
+++ b/lib/Service/RegistrationService.php
@@ -349,14 +349,17 @@ class RegistrationService {
$this->validateUsername($loginName);
- if ($this->config->getAppValue('registration', 'enfore_fullname', 'no') === 'yes') {
+ if ($this->config->getAppValue('registration', 'show_fullname', 'no') === 'yes'
+ && $this->config->getAppValue('registration', 'enforce_fullname', 'no') === 'yes') {
$this->validateDisplayname($fullName);
}
- if ($phone) {
- $this->validatePhoneNumber($phone);
- } elseif ($this->config->getAppValue('registration', 'enfore_phone', 'no') === 'yes') {
- throw new RegistrationException($this->l10n->t('Please provide a valid phone number.'));
+ if ($this->config->getAppValue('registration', 'show_phone', 'no') === 'yes') {
+ if ($phone) {
+ $this->validatePhoneNumber($phone);
+ } elseif ($this->config->getAppValue('registration', 'enforce_phone', 'no') === 'yes') {
+ throw new RegistrationException($this->l10n->t('Please provide a valid phone number.'));
+ }
}
/* TODO
@@ -381,12 +384,14 @@ class RegistrationService {
}
// Set display name
- if ($fullName) {
+ if ($fullName && $this->config->getAppValue('registration', 'show_fullname', 'no') === 'yes') {
$user->setDisplayName($fullName);
}
// Set phone number in account data
- if (method_exists($this->accountManager, 'updateAccount')) {
+ if (method_exists($this->accountManager, 'updateAccount')
+ && $phone
+ && $this->config->getAppValue('registration', 'show_phone', 'no') === 'yes') {
$account = $this->accountManager->getAccount($user);
$property = $account->getProperty(IAccountManager::PROPERTY_PHONE);
$account->setProperty(
diff --git a/lib/Settings/RegistrationSettings.php b/lib/Settings/RegistrationSettings.php
index 5036537..edebd13 100644
--- a/lib/Settings/RegistrationSettings.php
+++ b/lib/Settings/RegistrationSettings.php
@@ -54,13 +54,6 @@ class RegistrationSettings implements ISettings {
}
public function getForm(): TemplateResponse {
- // handle groups
- $groups = $this->groupManager->search('');
- $groupIds = [];
- foreach ($groups as $group) {
- $groupIds[] = $group->getGid();
- }
-
$this->initialState->provideInitialState(
'registered_user_group',
$this->getGroupDetailArray($this->config->getAppValue($this->appName, 'registered_user_group', 'none'))
@@ -87,15 +80,35 @@ class RegistrationSettings implements ISettings {
'disable_email_verification',
$this->config->getAppValue($this->appName, 'disable_email_verification', 'no') === 'yes'
);
+
$this->initialState->provideInitialState(
'email_is_login',
$this->config->getAppValue($this->appName, 'email_is_login', 'no') === 'yes'
);
-
$this->initialState->provideInitialState(
'username_policy_regex',
$this->config->getAppValue($this->appName, 'username_policy_regex')
);
+ $this->initialState->provideInitialState(
+ 'username_policy_regex',
+ $this->config->getAppValue($this->appName, 'username_policy_regex')
+ );
+ $this->initialState->provideInitialState(
+ 'show_fullname',
+ $this->config->getAppValue($this->appName, 'show_fullname', 'no') === 'yes'
+ );
+ $this->initialState->provideInitialState(
+ 'enforce_fullname',
+ $this->config->getAppValue($this->appName, 'enforce_fullname', 'no') === 'yes'
+ );
+ $this->initialState->provideInitialState(
+ 'show_phone',
+ $this->config->getAppValue($this->appName, 'show_phone', 'no') === 'yes'
+ );
+ $this->initialState->provideInitialState(
+ 'enforce_phone',
+ $this->config->getAppValue($this->appName, 'enforce_phone', 'no') === 'yes'
+ );
$this->initialState->provideInitialState(
'additional_hint',