mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
committed by
Petr Voborník
parent
77f0e9aba5
commit
b73fc6e550
@@ -34,6 +34,7 @@ IPA.field = function(spec) {
|
|||||||
that.name = spec.name;
|
that.name = spec.name;
|
||||||
that.label = spec.label;
|
that.label = spec.label;
|
||||||
that.tooltip = spec.tooltip;
|
that.tooltip = spec.tooltip;
|
||||||
|
that.formatter = spec.formatter;
|
||||||
|
|
||||||
that.widget = null;
|
that.widget = null;
|
||||||
that.widget_name = spec.widget;
|
that.widget_name = spec.widget;
|
||||||
@@ -194,7 +195,25 @@ IPA.field = function(spec) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
that.update = function() {
|
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 && i<that.values.length; i++) {
|
||||||
|
var value = that.values[i];
|
||||||
|
var formatted_value = that.formatter.format(value);
|
||||||
|
formatted_values.push(formatted_value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formatted_values = that.values;
|
||||||
|
}
|
||||||
|
|
||||||
|
that.widget.update(formatted_values);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.get_update_info = function() {
|
that.get_update_info = function() {
|
||||||
|
|||||||
@@ -466,46 +466,6 @@ IPA.host_dnsrecord_entity_link_field = function(spec){
|
|||||||
IPA.field_factories['host_dnsrecord_entity_link'] = IPA.host_dnsrecord_entity_link_field;
|
IPA.field_factories['host_dnsrecord_entity_link'] = IPA.host_dnsrecord_entity_link_field;
|
||||||
IPA.widget_factories['host_dnsrecord_entity_link'] = IPA.link_widget;
|
IPA.widget_factories['host_dnsrecord_entity_link'] = IPA.link_widget;
|
||||||
|
|
||||||
/* Take an LDAP format date in UTC and format it */
|
|
||||||
IPA.utc_date_column_formatter = function(spec) {
|
|
||||||
|
|
||||||
spec = spec || {};
|
|
||||||
|
|
||||||
var that = IPA.formatter(spec);
|
|
||||||
|
|
||||||
that.format = function(value) {
|
|
||||||
|
|
||||||
if (!value) return '';
|
|
||||||
|
|
||||||
// verify length
|
|
||||||
if (value.length != '20101119025910Z'.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;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
IPA.force_host_add_checkbox_widget = function(spec) {
|
IPA.force_host_add_checkbox_widget = function(spec) {
|
||||||
var metadata = IPA.get_command_option('host_add', spec.name);
|
var metadata = IPA.get_command_option('host_add', spec.name);
|
||||||
spec.label = metadata.label;
|
spec.label = metadata.label;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ json="{
|
|||||||
curl -v\
|
curl -v\
|
||||||
-H "Content-Type: application/json"\
|
-H "Content-Type: application/json"\
|
||||||
-H "Accept: applicaton/json"\
|
-H "Accept: applicaton/json"\
|
||||||
|
-H "Referer: https://`hostname`/ipa/xml"\
|
||||||
--negotiate\
|
--negotiate\
|
||||||
--delegation always\
|
--delegation always\
|
||||||
-u :\
|
-u :\
|
||||||
|
|||||||
@@ -335,6 +335,7 @@
|
|||||||
"contact": "Contact Settings",
|
"contact": "Contact Settings",
|
||||||
"employee": "Employee Information",
|
"employee": "Employee Information",
|
||||||
"error_changing_status": "Error changing account status",
|
"error_changing_status": "Error changing account status",
|
||||||
|
"krbpasswordexpiration": "Password expiration",
|
||||||
"mailing": "Mailing Address",
|
"mailing": "Mailing Address",
|
||||||
"misc": "Misc. Information",
|
"misc": "Misc. Information",
|
||||||
"status_confirmation": "Are you sure you want to ${action} the user?<br/>The change will take effect immediately.",
|
"status_confirmation": "Are you sure you want to ${action} the user?<br/>The change will take effect immediately.",
|
||||||
|
|||||||
@@ -82,6 +82,12 @@ IPA.user.entity = function(spec) {
|
|||||||
factory: IPA.user_password_widget,
|
factory: IPA.user_password_widget,
|
||||||
name: 'userpassword'
|
name: 'userpassword'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'krbpasswordexpiration',
|
||||||
|
label: IPA.messages.objects.user.krbpasswordexpiration,
|
||||||
|
read_only: true,
|
||||||
|
formatter: IPA.utc_date_formatter()
|
||||||
|
},
|
||||||
'uidnumber',
|
'uidnumber',
|
||||||
'gidnumber',
|
'gidnumber',
|
||||||
'loginshell',
|
'loginshell',
|
||||||
@@ -551,11 +557,11 @@ IPA.user_password_widget = function(spec) {
|
|||||||
|
|
||||||
that.show_dialog = function() {
|
that.show_dialog = function() {
|
||||||
|
|
||||||
that.pkey = IPA.nav.get_state('user-pkey');
|
var pkey = IPA.nav.get_state('user-pkey');
|
||||||
that.self_service = that.pkey === IPA.whoami.uid[0];
|
var self_service = pkey === IPA.whoami.uid[0];
|
||||||
|
|
||||||
var sections = [];
|
var sections = [];
|
||||||
if(that.self_service) {
|
if (self_service) {
|
||||||
sections.push({
|
sections.push({
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -600,7 +606,7 @@ IPA.user_password_widget = function(spec) {
|
|||||||
|
|
||||||
var current_password;
|
var current_password;
|
||||||
|
|
||||||
if (that.self_service) {
|
if (self_service) {
|
||||||
current_password = record.current_password[0];
|
current_password = record.current_password[0];
|
||||||
if (!current_password) {
|
if (!current_password) {
|
||||||
alert(IPA.messages.password.current_password_required);
|
alert(IPA.messages.password.current_password_required);
|
||||||
@@ -617,11 +623,15 @@ IPA.user_password_widget = function(spec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
that.set_password(
|
that.set_password(
|
||||||
|
pkey,
|
||||||
current_password,
|
current_password,
|
||||||
new_password,
|
new_password,
|
||||||
function(data, text_status, xhr) {
|
function(data, text_status, xhr) {
|
||||||
alert(IPA.messages.password.password_change_complete);
|
alert(IPA.messages.password.password_change_complete);
|
||||||
dialog.close();
|
dialog.close();
|
||||||
|
// refresh password expiration field
|
||||||
|
var facet = IPA.current_entity.get_facet();
|
||||||
|
facet.refresh();
|
||||||
},
|
},
|
||||||
function(xhr, text_status, error_thrown) {
|
function(xhr, text_status, error_thrown) {
|
||||||
dialog.close();
|
dialog.close();
|
||||||
@@ -641,18 +651,11 @@ IPA.user_password_widget = function(spec) {
|
|||||||
dialog.open(that.container);
|
dialog.open(that.container);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.set_password = function(current_password, password, on_success, on_error) {
|
that.set_password = function(pkey, current_password, password, on_success, on_error) {
|
||||||
|
|
||||||
var args;
|
|
||||||
if (that.self_service) {
|
|
||||||
args = [];
|
|
||||||
} else {
|
|
||||||
args = [that.pkey];
|
|
||||||
}
|
|
||||||
|
|
||||||
var command = IPA.command({
|
var command = IPA.command({
|
||||||
method: 'passwd',
|
method: 'passwd',
|
||||||
args: args,
|
args: [ pkey ],
|
||||||
options: {
|
options: {
|
||||||
current_password: current_password,
|
current_password: current_password,
|
||||||
password: password
|
password: password
|
||||||
|
|||||||
@@ -1054,6 +1054,45 @@ IPA.boolean_status_formatter = function(spec) {
|
|||||||
return that;
|
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
|
The entity name must be set in the spec either directly or via entity.name
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -474,6 +474,7 @@ class i18n_messages(Command):
|
|||||||
"contact": _("Contact Settings"),
|
"contact": _("Contact Settings"),
|
||||||
"employee": _("Employee Information"),
|
"employee": _("Employee Information"),
|
||||||
"error_changing_status": _("Error changing account status"),
|
"error_changing_status": _("Error changing account status"),
|
||||||
|
"krbpasswordexpiration": _("Password expiration"),
|
||||||
"mailing": _("Mailing Address"),
|
"mailing": _("Mailing Address"),
|
||||||
"misc": _("Misc. Information"),
|
"misc": _("Misc. Information"),
|
||||||
"status_confirmation": _("Are you sure you want to ${action} the user?<br/>The change will take effect immediately."),
|
"status_confirmation": _("Are you sure you want to ${action} the user?<br/>The change will take effect immediately."),
|
||||||
|
|||||||
Reference in New Issue
Block a user