diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2012-10-25 13:42:18 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2013-01-07 10:53:58 +0100 |
commit | e433379c469ab8dba80cb76f906d794e4f61b132 (patch) | |
tree | 54edbc10bf9400744a802c02fa8f8504f8179053 | |
parent | 3df18f5583ff96d505fe9249949bd4493df68172 (diff) | |
download | freeipa-e433379c469ab8dba80cb76f906d794e4f61b132.tar.gz freeipa-e433379c469ab8dba80cb76f906d794e4f61b132.tar.xz freeipa-e433379c469ab8dba80cb76f906d794e4f61b132.zip |
Standardize login password reset, user reset password and host set OTP dialogs
In all dialogs:
* validation notification was standardized
* can be confirmed by enter
User pwd dialog has fixed focus of first element.
https://fedorahosted.org/freeipa/ticket/2884
https://fedorahosted.org/freeipa/ticket/3200
Standartize password reset dialog
-rw-r--r-- | install/ui/field.js | 4 | ||||
-rw-r--r-- | install/ui/host.js | 38 | ||||
-rw-r--r-- | install/ui/ipa.js | 19 | ||||
-rw-r--r-- | install/ui/user.js | 36 |
4 files changed, 44 insertions, 53 deletions
diff --git a/install/ui/field.js b/install/ui/field.js index 612c8eb5a..ff807dcfc 100644 --- a/install/ui/field.js +++ b/install/ui/field.js @@ -510,8 +510,8 @@ IPA.same_password_validator = function(spec) { var that = IPA.validator(spec); that.other_field = spec.other_field; - that.message = spec.message || IPA.messages.password.password_must_match; - + that.message = spec.message || IPA.get_message('password.password_must_match', + "Passwords must match"); that.validate = function(value, context) { var other_field = context.container.fields.get_field(that.other_field); diff --git a/install/ui/host.js b/install/ui/host.js index 6aff2c50d..30086b414 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -780,18 +780,26 @@ IPA.host.set_otp_dialog = function(spec) { { name: 'password1', label: IPA.messages.password.new_password, - type: 'password' + type: 'password', + required: true }, { name: 'password2', label: IPA.messages.password.verify_password, - type: 'password' + type: 'password', + required: true, + validators: [IPA.same_password_validator({ + other_field: 'password1' + })] } ] } ]; var that = IPA.dialog(spec); + + IPA.confirm_mixin().apply(that); + that.facet = spec.facet; that.set_status = function(status) { @@ -807,27 +815,23 @@ IPA.host.set_otp_dialog = function(spec) { } }; + that.on_confirm = function() { + + if (!that.validate()) return; + + var new_password = that.fields.get_field('password1').save()[0]; + that.set_otp(new_password); + + that.close(); + }; + that.create_buttons = function() { that.create_button({ name: 'set_password', label: IPA.messages.objects.host.password_set_button, click: function() { - - var record = {}; - that.save(record); - - var new_password = record.password1[0]; - var repeat_password = record.password2[0]; - - if (new_password != repeat_password) { - alert(IPA.messages.password.password_must_match); - return; - } - - that.set_otp(new_password); - - that.close(); + that.on_confirm(); } }); diff --git a/install/ui/ipa.js b/install/ui/ipa.js index fa26a2ad0..cc62f0897 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -1672,7 +1672,10 @@ IPA.unauthorized_dialog = function(spec) { name: 'verify_password', type: 'password', required: true, - label: IPA.get_message('password.verify_password', "Verify Password") + label: IPA.get_message('password.verify_password', "Verify Password"), + validators: [IPA.same_password_validator({ + other_field: 'new_password' + })] } ] } @@ -1946,24 +1949,12 @@ IPA.unauthorized_dialog = function(spec) { var new_password = that.new_password_widget.save(); var verify_password = that.verify_password_widget.save(); - if (new_password[0] !== verify_password[0]) { - var message = IPA.get_message('password.password_must_match', - "Passwords must match"); - that.reset_error_box.html(message); - that.reset_error_box.css('display', 'block'); - return; - } else { - that.reset_error_box.css('display', 'none'); - } - - IPA.display_activity_icon(); + that.reset_error_box.css('display', 'none'); var result = IPA.reset_password(username[0], password[0], new_password[0]); - IPA.hide_activity_icon(); - if (result.status === 'ok') { that.on_reset_success(); } else { diff --git a/install/ui/user.js b/install/ui/user.js index d0f1f5af0..ac51db2ba 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -494,12 +494,18 @@ IPA.user_password_dialog = function(spec) { name: 'password2', label: IPA.messages.password.verify_password, type: 'password', + validators: [IPA.same_password_validator({ + other_field: 'password1' + })], required: true } ] }); var that = IPA.dialog(spec); + + IPA.confirm_mixin().apply(that); + that.success_handler = spec.on_success; that.error_handler = spec.on_error; that.self_service = spec.self_service; //option to force self-service @@ -524,9 +530,12 @@ IPA.user_password_dialog = function(spec) { var self_service = that.is_self_service(); var section = that.widgets.get_widget('input'); + var current_password_f = that.fields.get_field('current_password'); that.dialog_open(); section.set_row_visible('current_password', self_service); + current_password_f.set_required(self_service); + that.focus_first_element(); }; that.create_buttons = function() { @@ -546,37 +555,24 @@ IPA.user_password_dialog = function(spec) { }); }; + that.on_confirm = function() { + that.on_reset_click(); + }; + that.on_reset_click = function() { + if (!that.validate()) return; + var pkey = that.get_pkey(); var self_service = that.is_self_service(); var record = {}; that.save(record); - var current_password; - - if (self_service) { - current_password = record.current_password[0]; - if (!current_password) { - alert(IPA.messages.password.current_password_required); - return; - } - } - + var current_password = self_service ? record.current_password[0] : undefined; var new_password = record.password1[0]; var repeat_password = record.password2[0]; - if (IPA.is_empty(new_password)) { - alert(IPA.messages.password.new_password_required); - return; - } - - if (new_password != repeat_password) { - alert(IPA.messages.password.password_must_match); - return; - } - that.set_password( pkey, current_password, |