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 <simo@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Nathaniel McCallum 2014-05-05 10:41:20 -04:00 committed by Alexander Bokovoy
parent 5afa3c1815
commit db7d0219ba

View File

@ -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