Currently the user password is shown as follows in the details page:
Password: Reset Password
This is inconsistent with the rest of the page because the 'Reset
Password' is an action, not the value of the password.
Now password is shown as follows:
Password: ******* (if set)
Password: (if not set)
Reset password action was moved to Action List.
https://fedorahosted.org/freeipa/ticket/2248
Note: I will address enabling/disabling 'reset password' option in
action list in ticket #2318.
--
Petr Vobornik
From 5c2c5321f04fdec8b4889e0461ebd3af7c689a05 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Thu, 3 May 2012 10:48:23 +0200
Subject: [PATCH] Action list for user password
Currently the user password is shown as follows in the details page:
Password: Reset Password
This is inconsistent with the rest of the page because the 'Reset Password' is an action, not the value of the password.
Now password is shown as follows:
Password: ******* (if set)
Password: (if not set)
Reset password action was moved to Action List.
https://fedorahosted.org/freeipa/ticket/2248
---
install/ui/test/data/ipa_init.json | 1 +
install/ui/user.js | 203 ++++++++++++++++++++++--------------
ipalib/plugins/internal.py | 1 +
3 files changed, 128 insertions(+), 77 deletions(-)
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 8257d27c706e98e8904a43a0e258e193f47cd375..35842312255ef1df5cff033d49ea4b196e5143ea 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -425,6 +425,7 @@
"current_password": "Current Password",
"current_password_required": "Current password is required",
"new_password": "New Password",
+ "new_password_required": "New password is required",
"password_change_complete": "Password change complete",
"password_must_match": "Passwords must match",
"reset_password": "Reset Password",
diff --git a/install/ui/user.js b/install/ui/user.js
index ba25b006f6b149f34da8bffe91222ddb72267718..a835b1fd826ba29c2b343167be4a3a2c80e3b289 100644
--- a/install/ui/user.js
+++ b/install/ui/user.js
@@ -105,7 +105,8 @@ IPA.user.entity = function(spec) {
'uid',
{
factory: IPA.user_password_widget,
- name: 'userpassword'
+ name: 'has_password',
+ metadata: IPA.get_entity_param('user', 'userpassword')
},
{
name: 'krbpasswordexpiration',
@@ -228,7 +229,17 @@ IPA.user.entity = function(spec) {
actions: [
IPA.enable_action,
IPA.disable_action,
- IPA.delete_action
+ IPA.delete_action,
+ {
+ name: 'reset_password',
+ label: IPA.messages.password.reset_password,
+ handler: function() {
+ var dialog = IPA.user_password_dialog({
+ entity: that
+ });
+ dialog.open();
+ }
+ }
]
}
}).
@@ -422,118 +433,154 @@ IPA.user_adder_dialog = function(spec) {
IPA.user_password_widget = function(spec) {
spec = spec || {};
+ spec.read_only = true;
var that = IPA.input_widget(spec);
+ that.set_value = spec.set_value || '******';
+ that.unset_value = spec.unset_value || '';
that.create = function(container) {
that.widget_create(container);
- $('<a/>', {
- href: 'jslink',
- title: 'userpassword',
- text: IPA.messages.password.reset_password,
- click: function() {
- that.show_dialog();
- return false;
- }
+ that.display_control = $('<label/>', {
+ name: that.name
}).appendTo(container);
};
- that.show_dialog = function() {
+ that.update = function(values) {
- var pkey = IPA.nav.get_state('user-pkey');
- var self_service = pkey === IPA.whoami.uid[0];
-
- var sections = [];
- if (self_service) {
- sections.push({
- fields: [
- {
- name: 'current_password',
- label: IPA.messages.password.current_password,
- type: 'password'
- }
- ]
- });
+ if (values && values[0]) {
+ that.display_control.text(that.set_value);
+ } else {
+ that.display_control.text(that.unset_value);
}
+ };
- sections.push({
+ that.clear = function() {
+ that.display_control.text('');
+ };
+
+ return that;
+};
+
+IPA.user_password_dialog = function(spec) {
+
+ spec = spec || {};
+
+ spec.width = spec.width || 400;
+ spec.title = spec.title || IPA.messages.password.reset_password;
+ spec.sections = spec.sections || [];
+
+ spec.sections.push(
+ {
+ name: 'input',
fields: [
{
+ name: 'current_password',
+ label: IPA.messages.password.current_password,
+ type: 'password',
+ required: true
+ },
+ {
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
}
]
});
- var dialog = IPA.dialog({
- entity: that.entity,
- title: IPA.messages.password.reset_password,
- width: 400,
- sections: sections
- });
+ var that = IPA.dialog(spec);
+ that.get_pkey = function() {
+ return IPA.nav.get_state('user-pkey');
+ };
- dialog.create_button({
+ that.is_self_service = function() {
+ var pkey = that.get_pkey();
+ var self_service = pkey === IPA.whoami.uid[0];
+ return self_service;
+ };
+
+ that.open = function() {
+
+ var self_service = that.is_self_service();
+ var section = that.widgets.get_widget('input');
+
+ that.dialog_open();
+ section.set_row_visible('current_password', self_service);
+ };
+
+ that.create_buttons = function() {
+
+ that.create_button({
name: 'reset_password',
label: IPA.messages.password.reset_password,
- click: function() {
-
- var record = {};
- dialog.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 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_password(
- pkey,
- current_password,
- new_password,
- function(data, text_status, xhr) {
- alert(IPA.messages.password.password_change_complete);
- dialog.close();
- // refresh password expiration field
- var facet = IPA.current_entity.get_facet();
- facet.refresh();
- },
- function(xhr, text_status, error_thrown) {
- dialog.close();
- }
- );
- }
+ click: that.on_reset_click
});
- dialog.create_button({
+ that.create_button({
name: 'cancel',
label: IPA.messages.buttons.cancel,
click: function() {
- dialog.close();
+ that.close();
}
});
+ };
- dialog.open(that.container);
+ that.on_reset_click = function() {
+
+ 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 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,
+ new_password,
+ function(data, text_status, xhr) {
+ alert(IPA.messages.password.password_change_complete);
+ that.close();
+ // refresh password expiration field
+ var facet = IPA.current_entity.get_facet();
+ facet.refresh();
+ },
+ function(xhr, text_status, error_thrown) {
+ that.close();
+ }
+ );
};
that.set_password = function(pkey, current_password, password, on_success, on_error) {
@@ -552,6 +599,8 @@ IPA.user_password_widget = function(spec) {
command.execute();
};
+ that.create_buttons();
+
return that;
};
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 42737f7ff87d5616b0255e776082ae4d5a68b1bf..9ce27e0dcecb1cf2c44ed0ae4c366cbf038f1b66 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -564,6 +564,7 @@ class i18n_messages(Command):
"current_password": _("Current Password"),
"current_password_required": _("Current password is required"),
"new_password": _("New Password"),
+ "new_password_required": _("New password is required"),
"password_change_complete": _("Password change complete"),
"password_must_match": _("Passwords must match"),
"reset_password": _("Reset Password"),
--
1.7.7.6
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel