From 49dfee228d3cefe824de4e30d9e55b6902120cbe Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sun, 1 Sep 2019 11:50:28 +1000 Subject: [PATCH] Move update_requires_password setting to component setting This setting controls the business logic of a component and should be a component setting --- components/Account.php | 8 +++++++- lang/en/lang.php | 6 +++--- models/Settings.php | 1 - models/settings/fields.yaml | 8 -------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/components/Account.php b/components/Account.php index adfd7f37..3817f200 100644 --- a/components/Account.php +++ b/components/Account.php @@ -55,6 +55,12 @@ public function defineProperties() 'type' => 'checkbox', 'default' => 0 ], + 'requirePassword' => [ + 'title' => /*Confirm password on update*/'rainlab.user::lang.account.update_requires_password', + 'description' => /*Require the current password of the user when changing their profile.*/'rainlab.user::lang.account.update_requires_password_comment', + 'type' => 'checkbox', + 'default' => 0 + ], ]; } @@ -146,7 +152,7 @@ public function loginAttributeLabel() */ public function updateRequiresPassword() { - return UserSettings::get('update_requires_password', false); + return $this->property('requirePassword', false); } /** diff --git a/lang/en/lang.php b/lang/en/lang.php index 614bebab..7bcfda7c 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -98,8 +98,6 @@ 'remember_always' => 'Always', 'remember_never' => 'Never', 'remember_ask' => 'Ask the user on login', - 'update_requires_password' => 'Confirm current password on update', - 'update_requires_password_comment' => 'Require the current password of the user when changing their profile.' ], 'user' => [ 'label' => 'User', @@ -193,7 +191,9 @@ 'password' => 'Password', 'login' => 'Login', 'new_password' => 'New Password', - 'new_password_confirm' => 'Confirm New Password' + 'new_password_confirm' => 'Confirm New Password', + 'update_requires_password' => 'Confirm password on update', + 'update_requires_password_comment' => 'Require the current password of the user when changing their profile.' ], 'reset_password' => [ 'reset_password' => 'Reset Password', diff --git a/models/Settings.php b/models/Settings.php index 06ad9f85..b85dd3c8 100644 --- a/models/Settings.php +++ b/models/Settings.php @@ -34,7 +34,6 @@ public function initSettingsData() $this->block_persistence = false; $this->allow_registration = true; $this->login_attribute = self::LOGIN_EMAIL; - $this->update_requires_password = false; $this->remember_login = self::REMEMBER_ALWAYS; $this->use_register_throttle = true; } diff --git a/models/settings/fields.yaml b/models/settings/fields.yaml index 34fd3685..c01016c3 100644 --- a/models/settings/fields.yaml +++ b/models/settings/fields.yaml @@ -67,11 +67,3 @@ tabs: label: rainlab.user::lang.settings.activate_mode type: radio tab: rainlab.user::lang.settings.activation_tab - - # Require current password when editing profile - update_requires_password: - span: left - label: rainlab.user::lang.settings.update_requires_password - commentAbove: rainlab.user::lang.settings.update_requires_password_comment - type: switch - tab: rainlab.user::lang.settings.profile_tab