From db7d0219bac72daa270ee28d5db5c18ea41fb8b1 Mon Sep 17 00:00:00 2001 From: Nathaniel McCallum Date: Mon, 5 May 2014 10:41:20 -0400 Subject: Default the token owner to the person adding the token Creating tokens for yourself is the most common operation. Making this the default optimizes for the common case. Reviewed-By: Simo Sorce Reviewed-By: Jan Cholasta --- ipalib/plugins/otptoken.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ipalib/plugins/otptoken.py b/ipalib/plugins/otptoken.py index 027c28f85..b264287c3 100644 --- a/ipalib/plugins/otptoken.py +++ b/ipalib/plugins/otptoken.py @@ -244,7 +244,14 @@ class otptoken_add(LDAPCreate): if tattr in entry_attrs: del entry_attrs[tattr] - # Resolve the user's dn + # If owner was not specified, default to the person adding this token. + if 'ipatokenowner' not in entry_attrs: + result = self.api.Command.user_find(whoami=True)['result'] + if result: + cur_uid = result[0]['uid'][0] + entry_attrs.setdefault('ipatokenowner', cur_uid) + + # Resolve the owner's dn _normalize_owner(self.api.Object.user, entry_attrs) # Get the issuer for the URI -- cgit