mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user