diff --git a/hsadmin/cmd.py b/hsadmin/cmd.py index 7978133..8800a3d 100644 --- a/hsadmin/cmd.py +++ b/hsadmin/cmd.py @@ -88,15 +88,20 @@ def main(): if args.show_password: print(f'password: "{password}"') + action = 'reset' if p is not None else 'create' i = input( - f"Type yes to reset {user}'s password and send email to {address}\n" + f"Type yes to {action} {user}'s password and send email to {address!r}\n" ).strip() if i != "yes": print("Aborted") return - p.change_password(password) - print("password changed") + if p is None: + k.add_principal(user, password) + print("password created") + else: + p.change_password(password) + print("password changed") send_mail(args.admin, admin_pass, password, user, address) print("email sent")