Skip to content

Commit

Permalink
create-user command: full name is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-keeper committed Mar 8, 2024
1 parent fddd361 commit c3a8d44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion keepercommander/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
# Contact: ops@keepersecurity.com
#

__version__ = '16.10.7'
__version__ = '16.10.8'
25 changes: 10 additions & 15 deletions keepercommander/commands/enterprise_create_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,22 @@ def execute(self, params, **kwargs):
if len(nodes) > 1:
logging.warning('More than one nodes \"%s\" are found', node_name)
return
node_id = nodes[0]['node_id']

email = kwargs.get('email')
if not email:
logging.warning('Email parameter is required..')

node_id = nodes[0]['node_id']
emails = kwargs.get('email', [])
email_pattern = re.compile(EMAIL_PATTERN)

rq = enterprise_pb2.EnterpriseUsersProvisionRequest()
rq.clientVersion = rest_api.CLIENT_VERSION
tree_key = params.enterprise['unencrypted_tree_key']
name = kwargs.get('name') or ''

match = email_pattern.match(email)
if not match:
logging.warning('"%s" appears not a valid email address. Skipping.', email)
return

displayname = name if len(emails) == 1 else ''
tree_key = params.enterprise['unencrypted_tree_key']
displayname = kwargs.get('name') or ''

rq = enterprise_pb2.EnterpriseUsersProvisionRequest()
rq.clientVersion = rest_api.CLIENT_VERSION
data = {'displayname': displayname or email}
user_data = json.dumps(data).encode('utf-8')
user_password = generator.generate(20)
Expand Down Expand Up @@ -135,7 +131,6 @@ def execute(self, params, **kwargs):

login_facade = vault_extensions.LoginFacade()
ots_command = OneTimeShareCreateCommand()
records = []

folder_uid = None
folder_name = kwargs.get('folder')
Expand All @@ -152,7 +147,6 @@ def execute(self, params, **kwargs):
login_facade.notes = 'The user is required to change their Master Password upon login.'
record_management.add_record_to_folder(params, record, folder_uid=folder_uid)
api.sync_down(params)
records.append(record)
ots_url = ots_command.execute(params, record=record.record_uid, share_name=f'{email}: Master Password', expire='7d')
if ots_url:
record.custom.append(vault.TypedField.new_field('url', ots_url, 'One-Time Share'))
Expand All @@ -163,8 +157,8 @@ def execute(self, params, **kwargs):
print(f'The account {login_facade.login} has been created. Login details below:')
print(f'{"Vault Login URL:":>24s} {login_facade.url}')
print(f'{"Email:":>24s} {login_facade.login}')
if name:
print(f'{"Name:":>24s} {name}')
if displayname:
print(f'{"Name:":>24s} {displayname}')
if len(nodes) > 0:
node_name = (nodes[0].get('data') or {}).get('displayname') or ''
if node_name:
Expand All @@ -175,6 +169,7 @@ def execute(self, params, **kwargs):
print(f'{"Note:":>24s} {login_facade.notes}')
else:
logging.info('User \"%s\" credentials are stored to record \"%s\"', login_facade.login, login_facade.title)
return record.record_uid

@staticmethod
def resolve_folder(params, folder_name): # type: (KeeperParams, str) -> Optional[str]
Expand Down Expand Up @@ -229,4 +224,4 @@ def execute(self, params, **kwargs):
rqs = rqs[900:]
set_rq = enterprise_pb2.EnterpriseUserDataKeys()
set_rq.keys.extend(chunk)
api.communicate_rest(params, set_rq, 'enterprise/set_enterprise_users_data_keys')
api.communicate_rest(params, set_rq, 'enterprise/set_enterprise_users_data_keys')

0 comments on commit c3a8d44

Please sign in to comment.