create new password (principal) if does not exist

master
vuko 2021-11-13 10:50:09 +01:00
parent 756f6cbe66
commit 9ad4122061
1 changed files with 8 additions and 3 deletions

View File

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