summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Vomacka <pvomacka@redhat.com>2016-01-28 17:37:29 +0100
committerPetr Vobornik <pvoborni@redhat.com>2016-02-02 18:45:38 +0100
commitfb3b7f7d93060d42e9cc79768f72e0b2d4b0481f (patch)
tree686cc9f436e22bbf19115dec156f7efa56a21051
parent017b343e13bbfdd0d9951417be8dac4614cb1416 (diff)
downloadfreeipa-fb3b7f7d93060d42e9cc79768f72e0b2d4b0481f.tar.gz
freeipa-fb3b7f7d93060d42e9cc79768f72e0b2d4b0481f.tar.xz
freeipa-fb3b7f7d93060d42e9cc79768f72e0b2d4b0481f.zip
Add validation to Issue new certificate dialog
'Issue new certificate' dialog now validates whether user fills 'principal' and 'csr' field. In case that one of these fields is empty then it does not allow to submit the dialog. https://fedorahosted.org/freeipa/ticket/5432 Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
-rwxr-xr-xinstall/ui/src/freeipa/certificate.js60
-rw-r--r--install/ui/src/freeipa/details.js5
2 files changed, 45 insertions, 20 deletions
diff --git a/install/ui/src/freeipa/certificate.js b/install/ui/src/freeipa/certificate.js
index 93f3cfc68..aaae4d9fb 100755
--- a/install/ui/src/freeipa/certificate.js
+++ b/install/ui/src/freeipa/certificate.js
@@ -30,10 +30,11 @@ define([
'./reg',
'./rpc',
'./text',
+ './widget',
'./dialog'],
function(
lang, builder, metadata_provider, IPA, $, menu,
- phases, reg, rpc, text) {
+ phases, reg, rpc, text, widget_mod) {
var exp = IPA.cert = {};
@@ -399,11 +400,35 @@ IPA.cert.request_dialog = function(spec) {
spec = spec || {};
spec.sections = spec.sections || [];
- var section = { fields: [] };
- spec.sections.push(section);
+ var section0 = { fields: [] };
+ var section_csr = {
+ show_header: false,
+ fields: [
+ {
+ field: false,
+ $type: 'html',
+ name: 'message',
+ html: spec.message
+ },
+ {
+ $type: 'textarea',
+ name: 'csr',
+ required: true
+ }
+ ],
+ layout:
+ {
+ $factory: widget_mod.fluid_layout,
+ widget_cls: "col-sm-12 controls",
+ label_cls: "hide"
+ }
+ };
+
+ spec.sections.push(section0);
+ spec.sections.push(section_csr);
if (spec.show_principal) {
- section.fields.push(
+ section0.fields.push(
{
$type: 'text',
name: 'principal',
@@ -418,7 +443,7 @@ IPA.cert.request_dialog = function(spec) {
}
);
}
- section.fields.push(
+ section0.fields.push(
{
$type: 'entity_select',
name: 'profile_id',
@@ -443,7 +468,15 @@ IPA.cert.request_dialog = function(spec) {
click: function() {
var values = {};
that.save(values);
- var request = $.trim(that.textarea.val());
+
+ // check requested fields
+ if (!that.validate()) {
+ widget_mod.focus_invalid(that);
+ return;
+ }
+
+ // get csr from the textarea
+ var request = $.trim(that.get_field('csr').get_value());
values.request = IPA.cert.pem_csr_format(request);
if (that.request) {
@@ -461,19 +494,6 @@ IPA.cert.request_dialog = function(spec) {
}
});
- that.create_content = function() {
- that.dialog_create_content();
- var node = $("<div/>", {
- 'class': 'col-sm-12'
- });
- node.append(that.message);
- that.textarea = $('<textarea/>', {
- 'class': 'certificate'
- }).appendTo(node);
- that.body_node.append(node);
- return that.body_node;
- };
-
return that;
};
@@ -1519,4 +1539,4 @@ phases.on('post-metadata', exp.create_cert_metadata);
phases.on('profile', exp.remove_menu_item, 20);
return exp;
-}); \ No newline at end of file
+});
diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js
index bb3e3ec21..080df1e7d 100644
--- a/install/ui/src/freeipa/details.js
+++ b/install/ui/src/freeipa/details.js
@@ -295,6 +295,11 @@ exp.section_builder = IPA.section_builder = function(spec) {
var widget = that.widget_builder.build_widget(field_spec, section.widgets);
+ if (field_spec.field === false) {
+ // widget doesn't have field, skip
+ return;
+ }
+
if (section.$field_adapter && !field_spec.adapter) {
field_spec.adapter = section.$field_adapter;
}