mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
User password widget modified.
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 link was removed as well the dialog for reset password was removed from password widget. The dialog was moved to its own object and can be now showed independently. An action for showing this dialog should be created. https://fedorahosted.org/freeipa/ticket/2248
This commit is contained in:
parent
890151dca8
commit
ea5ae4b1cf
@ -425,6 +425,7 @@
|
|||||||
"current_password": "Current Password",
|
"current_password": "Current Password",
|
||||||
"current_password_required": "Current password is required",
|
"current_password_required": "Current password is required",
|
||||||
"new_password": "New Password",
|
"new_password": "New Password",
|
||||||
|
"new_password_required": "New password is required",
|
||||||
"password_change_complete": "Password change complete",
|
"password_change_complete": "Password change complete",
|
||||||
"password_must_match": "Passwords must match",
|
"password_must_match": "Passwords must match",
|
||||||
"reset_password": "Reset Password",
|
"reset_password": "Reset Password",
|
||||||
|
@ -107,7 +107,8 @@ IPA.user.entity = function(spec) {
|
|||||||
'uid',
|
'uid',
|
||||||
{
|
{
|
||||||
factory: IPA.user_password_widget,
|
factory: IPA.user_password_widget,
|
||||||
name: 'userpassword'
|
name: 'has_password',
|
||||||
|
metadata: IPA.get_entity_param('user', 'userpassword')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'krbpasswordexpiration',
|
name: 'krbpasswordexpiration',
|
||||||
@ -430,118 +431,154 @@ IPA.user_adder_dialog = function(spec) {
|
|||||||
IPA.user_password_widget = function(spec) {
|
IPA.user_password_widget = function(spec) {
|
||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
spec.read_only = true;
|
||||||
|
|
||||||
var that = IPA.input_widget(spec);
|
var that = IPA.input_widget(spec);
|
||||||
|
that.set_value = spec.set_value || '******';
|
||||||
|
that.unset_value = spec.unset_value || '';
|
||||||
|
|
||||||
that.create = function(container) {
|
that.create = function(container) {
|
||||||
|
|
||||||
that.widget_create(container);
|
that.widget_create(container);
|
||||||
|
|
||||||
$('<a/>', {
|
that.display_control = $('<label/>', {
|
||||||
href: 'jslink',
|
name: that.name
|
||||||
title: 'userpassword',
|
|
||||||
text: IPA.messages.password.reset_password,
|
|
||||||
click: function() {
|
|
||||||
that.show_dialog();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).appendTo(container);
|
}).appendTo(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.show_dialog = function() {
|
that.update = function(values) {
|
||||||
|
|
||||||
var pkey = IPA.nav.get_state('user-pkey');
|
if (values && values[0]) {
|
||||||
var self_service = pkey === IPA.whoami.uid[0];
|
that.display_control.text(that.set_value);
|
||||||
|
} else {
|
||||||
var sections = [];
|
that.display_control.text(that.unset_value);
|
||||||
if (self_service) {
|
|
||||||
sections.push({
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
name: 'current_password',
|
|
||||||
label: IPA.messages.password.current_password,
|
|
||||||
type: 'password'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
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: [
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'current_password',
|
||||||
|
label: IPA.messages.password.current_password,
|
||||||
|
type: 'password',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'password1',
|
name: 'password1',
|
||||||
label: IPA.messages.password.new_password,
|
label: IPA.messages.password.new_password,
|
||||||
type: 'password'
|
type: 'password',
|
||||||
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'password2',
|
name: 'password2',
|
||||||
label: IPA.messages.password.verify_password,
|
label: IPA.messages.password.verify_password,
|
||||||
type: 'password'
|
type: 'password',
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog = IPA.dialog({
|
var that = IPA.dialog(spec);
|
||||||
entity: that.entity,
|
|
||||||
title: IPA.messages.password.reset_password,
|
|
||||||
width: 400,
|
|
||||||
sections: sections
|
|
||||||
});
|
|
||||||
|
|
||||||
|
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',
|
name: 'reset_password',
|
||||||
label: IPA.messages.password.reset_password,
|
label: IPA.messages.password.reset_password,
|
||||||
click: function() {
|
click: that.on_reset_click
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.create_button({
|
that.create_button({
|
||||||
name: 'cancel',
|
name: 'cancel',
|
||||||
label: IPA.messages.buttons.cancel,
|
label: IPA.messages.buttons.cancel,
|
||||||
click: function() {
|
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) {
|
that.set_password = function(pkey, current_password, password, on_success, on_error) {
|
||||||
@ -560,6 +597,8 @@ IPA.user_password_widget = function(spec) {
|
|||||||
command.execute();
|
command.execute();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.create_buttons();
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -564,6 +564,7 @@ class i18n_messages(Command):
|
|||||||
"current_password": _("Current Password"),
|
"current_password": _("Current Password"),
|
||||||
"current_password_required": _("Current password is required"),
|
"current_password_required": _("Current password is required"),
|
||||||
"new_password": _("New Password"),
|
"new_password": _("New Password"),
|
||||||
|
"new_password_required": _("New password is required"),
|
||||||
"password_change_complete": _("Password change complete"),
|
"password_change_complete": _("Password change complete"),
|
||||||
"password_must_match": _("Passwords must match"),
|
"password_must_match": _("Passwords must match"),
|
||||||
"reset_password": _("Reset Password"),
|
"reset_password": _("Reset Password"),
|
||||||
|
Loading…
Reference in New Issue
Block a user