Skip to content

Commit

Permalink
Move update_requires_password setting to component setting
Browse files Browse the repository at this point in the history
This setting controls the business logic of a component and should be a component setting
  • Loading branch information
Samuel Georges committed Sep 1, 2019
1 parent 243ab40 commit 49dfee2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
8 changes: 7 additions & 1 deletion components/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
];
}

Expand Down Expand Up @@ -146,7 +152,7 @@ public function loginAttributeLabel()
*/
public function updateRequiresPassword()
{
return UserSettings::get('update_requires_password', false);
return $this->property('requirePassword', false);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
1 change: 0 additions & 1 deletion models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 0 additions & 8 deletions models/settings/fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 49dfee2

Please sign in to comment.