diff options
author | Pavel Vomacka <pvomacka@redhat.com> | 2016-03-30 10:19:39 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2016-06-02 18:38:32 +0200 |
commit | 3b37e29ac6e918027b06e574c2c793f6c521100c (patch) | |
tree | 5bfece037cea29c7a33e00b60d61a809c6dbc13d | |
parent | f077fab23fe9dc8a71562d1ba3c0d603d2957d3b (diff) | |
download | freeipa-3b37e29ac6e918027b06e574c2c793f6c521100c.tar.gz freeipa-3b37e29ac6e918027b06e574c2c793f6c521100c.tar.xz freeipa-3b37e29ac6e918027b06e574c2c793f6c521100c.zip |
Add option to show OTP when adding host
Add option to add host dialog which allows to show generated OTP.
This patch also changed the way of informing user about success of adding host
but only when the 'Generate OTP' option is checked. There is a new dialog with
generated OTP.
https://fedorahosted.org/freeipa/ticket/4602
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
-rw-r--r-- | install/ui/src/freeipa/add.js | 6 | ||||
-rw-r--r-- | install/ui/src/freeipa/host.js | 60 | ||||
-rw-r--r-- | install/ui/test/data/ipa_init.json | 3 | ||||
-rw-r--r-- | ipalib/plugins/internal.py | 3 |
4 files changed, 69 insertions, 3 deletions
diff --git a/install/ui/src/freeipa/add.js b/install/ui/src/freeipa/add.js index 8f24c7733..622108526 100644 --- a/install/ui/src/freeipa/add.js +++ b/install/ui/src/freeipa/add.js @@ -84,7 +84,7 @@ IPA.entity_adder_dialog = function(spec) { that.hide_message(); that.add( function(data, text_status, xhr) { - that.added.notify([data], that); + that.added.notify([data, 'add_and_add_another'], that); that.show_message(that.get_success_message(data), 'success'); that.reset(); that.focus_first_element(); @@ -100,7 +100,7 @@ IPA.entity_adder_dialog = function(spec) { that.hide_message(); that.add( function(data, text_status, xhr) { - that.added.notify([data], that); + that.added.notify([data, 'add_and_edit'], that); that.close(); var result = data.result.result; that.show_edit_page(that.entity, result); @@ -129,7 +129,7 @@ IPA.entity_adder_dialog = function(spec) { that.hide_message(); that.add( function(data, text_status, xhr) { - that.added.notify([data], that); + that.added.notify([data, 'add'], that); that.close(); that.notify_success(data); }, diff --git a/install/ui/src/freeipa/host.js b/install/ui/src/freeipa/host.js index 764e551b4..817e62efc 100644 --- a/install/ui/src/freeipa/host.js +++ b/install/ui/src/freeipa/host.js @@ -347,6 +347,12 @@ return { $type: 'force_host_add_checkbox', name: 'force', metadata: '@mc-opt:host_add:force' + }, + { + $type: 'checkbox', + name: 'random', + label: '@i18n:objects.host.generate_otp', + title: '@i18n:objects.host.generate_otp' } ] } @@ -529,13 +535,67 @@ IPA.host_adder_dialog = function(spec) { var that = IPA.entity_adder_dialog(spec); + that.init = function() { + that.added.attach(that.handle_random_otp); + }; + that.create_content = function() { that.entity_adder_dialog_create_content(); that.container.addClass('host-adder-dialog'); }; + that.create_result_dialog = function() { + spec = { + title: text.get('@i18n:dialogs.result'), + sections: [ + { + show_header: false, + fields: [ + { + $type: 'text', + name: 'randompassword', + label: '@i18n:objects.host.generated_otp', + read_only: true + } + ] + } + ] + }; + + var dialog = IPA.dialog(spec); + + dialog.create_button({ + name: 'close', + label: text.get('@i18n:buttons.close'), + click: function() { + dialog.close(); + } + }); + + + return dialog; + }; + + that.handle_random_otp = function(data, method) { + var dialog = that.create_result_dialog(); + var random_passwd = that.get_field('random').get_value()[0]; + + if ((method === 'add' || method === 'add_and_edit') && random_passwd) { + var field = dialog.get_field('randompassword'); + dialog.open(); + field.load(data); + } + else if (method === 'add_and_add_another' && random_passwd) { + var message = text.get('@i18n:objects.host.generated_otp') + + ": " + data.result.result.randompassword; + that.show_message(message); + } + }; + that.on_error = rpc.create_4304_error_handler(that); + that.init(); + return that; }; diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json index 1b9b69ff9..6ed7e9824 100644 --- a/install/ui/test/data/ipa_init.json +++ b/install/ui/test/data/ipa_init.json @@ -119,6 +119,7 @@ "redirection": "Redirection", "remove_empty": "Select entries to be removed.", "remove_title": "Remove ${entity}", + "result": "Result", "show_details": "Show details", "success": "Success", "validation_message": "Input form contains invalid or missing values.", @@ -382,6 +383,8 @@ "enrolled": "Enrolled", "enrollment": "Enrollment", "fqdn": "Fully Qualified Host Name", + "generate_otp": "Generate OTP", + "generated_otp": "Generated OTP", "keytab": "Kerberos Key", "keytab_missing": "Kerberos Key Not Present", "keytab_present": "Kerberos Key Present, Host Provisioned", diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py index c28693a46..175063ba1 100644 --- a/ipalib/plugins/internal.py +++ b/ipalib/plugins/internal.py @@ -262,6 +262,7 @@ class i18n_messages(Command): "redirection": _("Redirection"), "remove_empty": _("Select entries to be removed."), "remove_title": _("Remove ${entity}"), + "result": _("Result"), "show_details": _("Show details"), "success": _("Success"), "validation_title": _("Validation error"), @@ -527,6 +528,8 @@ class i18n_messages(Command): "enrolled": _("Enrolled"), "enrollment": _("Enrollment"), "fqdn": _("Fully Qualified Host Name"), + "generate_otp": _("Generate OTP"), + "generated_otp": _("Generated OTP"), "keytab": _("Kerberos Key"), "keytab_missing": _("Kerberos Key Not Present"), "keytab_present": _("Kerberos Key Present, Host Provisioned"), |