diff --git a/plugins/change-password/index.php b/plugins/change-password/index.php index 47ecac4fd..aa87c9395 100644 --- a/plugins/change-password/index.php +++ b/plugins/change-password/index.php @@ -6,8 +6,8 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin { const NAME = 'Change Password', - VERSION = '2.16.3', - RELEASE = '2022-10-14', + VERSION = '2.16.4', + RELEASE = '2022-11-09', REQUIRED = '2.12.0', CATEGORY = 'Security', DESCRIPTION = 'Extension to allow users to change their passwords'; @@ -106,12 +106,14 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin ->SetLabel('Password minimum length') ->SetType(\RainLoop\Enumerations\PluginPropertyType::INT) ->SetDescription('Minimum length of the password') - ->SetDefaultValue(10), + ->SetDefaultValue(10) + ->SetAllowedInJs(true), \RainLoop\Plugins\Property::NewInstance("pass_min_strength") ->SetLabel('Password minimum strength') ->SetType(\RainLoop\Enumerations\PluginPropertyType::INT) ->SetDescription('Minimum strength of the password in %') - ->SetDefaultValue(70), + ->SetDefaultValue(70) + ->SetAllowedInJs(true), ]; foreach ($this->getSupportedDrivers(true) as $name => $class) { $group = new \RainLoop\Plugins\PropertyCollection($name); diff --git a/plugins/change-password/js/ChangePasswordUserSettings.js b/plugins/change-password/js/ChangePasswordUserSettings.js index 59dc236a5..8ec0ad048 100644 --- a/plugins/change-password/js/ChangePasswordUserSettings.js +++ b/plugins/change-password/js/ChangePasswordUserSettings.js @@ -34,6 +34,9 @@ class ChangePasswordUserSettings { constructor() { + let minLength = rl.pluginSettingsGet('change-password', 'pass_min_length'); + let minStrength = rl.pluginSettingsGet('change-password', 'pass_min_strength'); + this.changeProcess = ko.observable(false); this.errorDescription = ko.observable(''); this.passwordMismatch = ko.observable(false); @@ -43,6 +46,7 @@ this.currentPasswordError = ko.observable(false); this.newPassword = ko.observable(''); this.newPassword2 = ko.observable(''); + this.pass_min_length = minLength; this.currentPassword.subscribe(() => this.resetUpdate(true)); this.newPassword.subscribe(() => this.resetUpdate()); @@ -51,11 +55,16 @@ ko.decorateCommands(this, { saveNewPasswordCommand: self => !self.changeProcess() && '' !== self.currentPassword() - && '' !== self.newPassword() - && '' !== self.newPassword2() + && self.newPassword().length >= minLength + && self.newPassword2() == self.newPassword() + && (!this.meter || this.meter.value >= minStrength) }); } + submitForm(form) { + form.reportValidity() && this.saveNewPasswordCommand(); + } + saveNewPasswordCommand() { if (this.newPassword() !== this.newPassword2()) { this.passwordMismatch(true); @@ -111,6 +120,7 @@ onBuild(dom) { let meter = dom.querySelector('.new-password-meter'); meter && this.newPassword.subscribe(value => meter.value = getPassStrength(value)); + this.meter = meter; } onHide() { diff --git a/plugins/change-password/templates/SettingsChangePassword.html b/plugins/change-password/templates/SettingsChangePassword.html index 83f9bd215..69cda54b1 100644 --- a/plugins/change-password/templates/SettingsChangePassword.html +++ b/plugins/change-password/templates/SettingsChangePassword.html @@ -1,5 +1,5 @@
-
+
@@ -14,7 +14,7 @@
+ data-bind="textInput: newPassword, attr:{minlength:pass_min_length}" />
@@ -28,10 +28,10 @@