From b73fc6e550fed9a1b6d83a03fa16f43b361ec8aa Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Tue, 31 Jan 2012 13:41:28 -0600 Subject: Show password expiration date. The user details page was modified to show the password expiration date next to the existing password field. Fixed problem resetting password in self-service mode. The JSON interface for the passwd command requires the username to be specified although the equivalent CLI command doesn't require it. Ticket #2064 --- install/ui/field.js | 21 +++++++++++++++++- install/ui/host.js | 40 ---------------------------------- install/ui/test/bin/update_ipa_init.sh | 1 + install/ui/test/data/ipa_init.json | 1 + install/ui/user.js | 29 +++++++++++++----------- install/ui/widget.js | 39 +++++++++++++++++++++++++++++++++ 6 files changed, 77 insertions(+), 54 deletions(-) (limited to 'install/ui') diff --git a/install/ui/field.js b/install/ui/field.js index c448c41c..38d71b47 100644 --- a/install/ui/field.js +++ b/install/ui/field.js @@ -34,6 +34,7 @@ IPA.field = function(spec) { that.name = spec.name; that.label = spec.label; that.tooltip = spec.tooltip; + that.formatter = spec.formatter; that.widget = null; that.widget_name = spec.widget; @@ -194,7 +195,25 @@ IPA.field = function(spec) { }; that.update = function() { - if(that.widget && that.widget.update) that.widget.update(that.values); + + if (!that.widget || !that.widget.update) return; + + var formatted_values; + + // The formatter is currently only used on read-only fields only + // because it cannot parse formatted values back to internal values. + if (that.formatter && that.read_only) { + formatted_values = []; + for (var i=0; that.values && iThe change will take effect immediately.", diff --git a/install/ui/user.js b/install/ui/user.js index a0cecc7b..b1dd8a61 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -82,6 +82,12 @@ IPA.user.entity = function(spec) { factory: IPA.user_password_widget, name: 'userpassword' }, + { + name: 'krbpasswordexpiration', + label: IPA.messages.objects.user.krbpasswordexpiration, + read_only: true, + formatter: IPA.utc_date_formatter() + }, 'uidnumber', 'gidnumber', 'loginshell', @@ -551,11 +557,11 @@ IPA.user_password_widget = function(spec) { that.show_dialog = function() { - that.pkey = IPA.nav.get_state('user-pkey'); - that.self_service = that.pkey === IPA.whoami.uid[0]; + var pkey = IPA.nav.get_state('user-pkey'); + var self_service = pkey === IPA.whoami.uid[0]; var sections = []; - if(that.self_service) { + if (self_service) { sections.push({ fields: [ { @@ -600,7 +606,7 @@ IPA.user_password_widget = function(spec) { var current_password; - if (that.self_service) { + if (self_service) { current_password = record.current_password[0]; if (!current_password) { alert(IPA.messages.password.current_password_required); @@ -617,11 +623,15 @@ IPA.user_password_widget = function(spec) { } 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(); @@ -641,18 +651,11 @@ IPA.user_password_widget = function(spec) { dialog.open(that.container); }; - that.set_password = function(current_password, password, on_success, on_error) { - - var args; - if (that.self_service) { - args = []; - } else { - args = [that.pkey]; - } + that.set_password = function(pkey, current_password, password, on_success, on_error) { var command = IPA.command({ method: 'passwd', - args: args, + args: [ pkey ], options: { current_password: current_password, password: password diff --git a/install/ui/widget.js b/install/ui/widget.js index 5ab28cb6..04c35bb6 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -1054,6 +1054,45 @@ IPA.boolean_status_formatter = function(spec) { return that; }; +/* Take an LDAP format date in UTC and format it */ +IPA.utc_date_formatter = function(spec) { + + spec = spec || {}; + + var that = IPA.formatter(spec); + + that.format = function(value) { + + if (!value) return ''; + + // verify length + if (value.length != 'YYYYmmddHHMMSSZ'.length) { + return value; + } + + /* We only handle GMT */ + if (value.charAt(value.length -1) !== 'Z') { + return value; + } + + var date = new Date(); + + date.setUTCFullYear( + value.substring(0, 4), // YYYY + value.substring(4, 6)-1, // mm (0-11) + value.substring(6, 8)); // dd (1-31) + + date.setUTCHours( + value.substring(8, 10), // HH (0-23) + value.substring(10, 12), // MM (0-59) + value.substring(12, 14)); // SS (0-59) + + return date.toString(); + }; + + return that; +}; + /* The entity name must be set in the spec either directly or via entity.name */ -- cgit