summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2012-06-18 15:46:33 +0200
committerMartin Kosek <mkosek@redhat.com>2012-06-26 12:32:50 +0200
commitd1fe43c56fe211db035bd6a30ac06fcfc6f61557 (patch)
tree1086e41213769211a5487a60a1967f35e878a1eb /install
parentae19cce7adcb08cc192a9a2b320a09ab10269f52 (diff)
downloadfreeipa-d1fe43c56fe211db035bd6a30ac06fcfc6f61557.tar.gz
freeipa-d1fe43c56fe211db035bd6a30ac06fcfc6f61557.tar.xz
freeipa-d1fe43c56fe211db035bd6a30ac06fcfc6f61557.zip
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
Diffstat (limited to 'install')
-rw-r--r--install/ui/add.js1
-rw-r--r--install/ui/details.js1
-rw-r--r--install/ui/field.js24
3 files changed, 26 insertions, 0 deletions
diff --git a/install/ui/add.js b/install/ui/add.js
index a9969a5cb..eafcd0d57 100644
--- a/install/ui/add.js
+++ b/install/ui/add.js
@@ -128,6 +128,7 @@ IPA.entity_adder_dialog = function(spec) {
var values = record[field.param];
if (!values || values.length === 0) continue;
+ if (field.flags.indexOf('no_command') > -1) continue;
if (field.param === pkey_name) {
command.add_arg(values[0]);
diff --git a/install/ui/details.js b/install/ui/details.js
index 48c8adb60..65de28442 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -521,6 +521,7 @@ IPA.details_facet = function(spec, no_init) {
for (var i=0; i < update_info.fields.length; i++) {
var field_info = update_info.fields[i];
+ if (field_info.field.flags.indexOf('no_command') > -1) continue;
var values = field_info.field.save();
IPA.command_builder.add_field_option(
command,
diff --git a/install/ui/field.js b/install/ui/field.js
index 03401dffd..84ec0c4df 100644
--- a/install/ui/field.js
+++ b/install/ui/field.js
@@ -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 || {};