mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Same password validator
This patch adds validator which compares passwords in two fields. In future it should be used in various password reset dialogs. A flags attribute was added to field. It's purpose is to define control flags. This patch uses it in details facet and adder dialog to not include fields to command option if the field has 'no_command' flag. Therefore there is no need to use hacks such as disabling of field or removing a value from command's option map when a non-command field is needed (ie verify password). https://fedorahosted.org/freeipa/ticket/2829
This commit is contained in:
committed by
Martin Kosek
parent
ae19cce7ad
commit
d1fe43c56f
@@ -50,6 +50,7 @@ IPA.field = function(spec) {
|
||||
that.writable = true;
|
||||
|
||||
that.enabled = spec.enabled === undefined ? true : spec.enabled;
|
||||
that.flags = spec.flags || [];
|
||||
|
||||
that.undo = spec.undo === undefined ? true : spec.undo;
|
||||
|
||||
@@ -480,6 +481,29 @@ IPA.unsupported_validator = function(spec) {
|
||||
return that;
|
||||
};
|
||||
|
||||
IPA.same_password_validator = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = IPA.validator(spec);
|
||||
that.other_field = spec.other_field;
|
||||
|
||||
that.message = spec.message || IPA.messages.password.password_must_match;
|
||||
|
||||
that.validate = function(value, context) {
|
||||
|
||||
var other_field = context.container.fields.get_field(that.other_field);
|
||||
var other_value = other_field.save();
|
||||
var this_value = context.save();
|
||||
|
||||
if (IPA.array_diff(this_value, other_value)) return that.false_result();
|
||||
|
||||
return that.true_result();
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
IPA.checkbox_field = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
Reference in New Issue
Block a user