summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2014-07-28 10:27:36 +0200
committerPetr Vobornik <pvoborni@redhat.com>2014-09-11 17:55:17 +0200
commit325bbf5bbf39da43e590b2dee2044683aaec3a66 (patch)
tree7cd8d52d0a1345204c5bf7f98d2972866676163b
parent475f6e293e3341f72f56bd9b75e6dc6231a10a59 (diff)
downloadfreeipa-325bbf5bbf39da43e590b2dee2044683aaec3a66.zip
freeipa-325bbf5bbf39da43e590b2dee2044683aaec3a66.tar.gz
freeipa-325bbf5bbf39da43e590b2dee2044683aaec3a66.tar.xz
webui: add token from user page
Add 'Add OTP Token' action to user action menu. This option is disabled in self-service when viewing other users. https://fedorahosted.org/freeipa/ticket/4402 Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
-rw-r--r--install/ui/src/freeipa/user.js61
-rw-r--r--install/ui/test/data/ipa_init.json1
-rw-r--r--ipalib/plugins/internal.py1
3 files changed, 60 insertions, 3 deletions
diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js
index b595d06..9872df2 100644
--- a/install/ui/src/freeipa/user.js
+++ b/install/ui/src/freeipa/user.js
@@ -269,7 +269,7 @@ return {
}
],
actions: [
- 'select',
+ 'add_otptoken',
'enable',
'disable',
'delete',
@@ -288,7 +288,7 @@ return {
label: '@i18n:actions.automember_rebuild'
}
],
- header_actions: ['reset_password', 'enable', 'disable', 'delete', 'unlock', 'automember_rebuild'],
+ header_actions: ['reset_password', 'enable', 'disable', 'delete', 'unlock', 'add_otptoken', 'automember_rebuild'],
state: {
evaluators: [
{
@@ -302,7 +302,8 @@ return {
name: 'reset_password_acl_evaluator',
adapter: { $type: 'batch', result_index: 0 },
attribute: 'userpassword'
- }
+ },
+ IPA.user.self_service_other_user_evaluator
],
summary_conditions: [
IPA.enabled_summary_cond,
@@ -608,6 +609,59 @@ IPA.user.reset_password_action = function(spec) {
return that;
};
+
+IPA.user.add_otptoken_action = function(spec) {
+
+ spec = spec || {};
+ spec.name = spec.name || 'add_otptoken';
+ spec.label = spec.label || '@i18n:objects.otptoken.add_token';
+ spec.disable_cond = spec.disable_cond || ['self-service-other'];
+
+ var that = IPA.action(spec);
+
+ that.execute_action = function(facet) {
+
+ var otp_e = reg.entity.get('otptoken');
+ var dialog = otp_e.get_dialog('add');
+ dialog.open();
+ if (!IPA.is_selfservice) {
+ var owner = facet.get_pkey();
+ dialog.get_field('ipatokenowner').set_value([owner]);
+ }
+ };
+
+ return that;
+};
+
+IPA.user.self_service_other_user_evaluator = function(spec) {
+
+ spec = spec || {};
+ spec.event = spec.event || 'post_load';
+
+ var that = IPA.state_evaluator(spec);
+ that.name = spec.name || 'self_service_other_user_evaluator';
+ that.param = spec.param || 'uid';
+ that.adapter = builder.build('adapter', spec.adapter || 'adapter', { context: that });
+
+ /**
+ * Evaluates if user is in self-service and viewing himself
+ */
+ that.on_event = function(data) {
+
+ var old_state = that.state;
+ that.state = [];
+
+ var value = that.adapter.load(data);
+ if (IPA.is_selfservice && IPA.whoami.uid[0] !== value[0]) {
+ that.state.push('self-service-other');
+ }
+
+ that.notify_on_change(old_state);
+ };
+
+ return that;
+};
+
exp.entity_spec = make_spec();
exp.register = function() {
var e = reg.entity;
@@ -615,6 +669,7 @@ exp.register = function() {
var d = reg.dialog;
e.register({type: 'user', spec: exp.entity_spec});
a.register('reset_password', IPA.user.reset_password_action);
+ a.register('add_otptoken', IPA.user.add_otptoken_action);
d.copy('password', 'user_password', {
factory: IPA.user.password_dialog,
pre_ops: [IPA.user.password_dialog_pre_op]
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 6d1cfc5..857f8ee 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -376,6 +376,7 @@
"users": "Users"
},
"otptoken": {
+ "add_token": "Add OTP Token",
"details": "OTP Token Settings",
"disable": "Disable token",
"enable": "Enable token",
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 6f110f1..e4ebac0 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -520,6 +520,7 @@ class i18n_messages(Command):
"users": _("Users"),
},
"otptoken": {
+ "add_token": _("Add OTP Token"),
"details": _("OTP Token Settings"),
"disable": _("Disable token"),
"enable": _("Enable token"),