diff --git a/tools/mail.py b/tools/mail.py index b1a175e8..688fac44 100755 --- a/tools/mail.py +++ b/tools/mail.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -import sys, urllib.request, urllib.error +import sys, getpass, urllib.request, urllib.error def mgmt(cmd, data=None): req = urllib.request.Request('http://localhost:10222' + cmd, urllib.parse.urlencode(data).encode("utf8") if data else None) @@ -11,6 +11,15 @@ def mgmt(cmd, data=None): sys.exit(1) return response.read().decode('utf8') +def read_password(): + first = getpass.getpass('password: ') + second = getpass.getpass(' (again): ') + while first != second: + print('Passwords not the same. Try again.') + first = getpass.getpass('password: ') + second = getpass.getpass(' (again): ') + return first + if len(sys.argv) < 2: print("Usage: ") print(" tools/mail.py user (lists users)") @@ -33,7 +42,7 @@ elif sys.argv[1] == "user" and sys.argv[2] in ("add", "password"): email = input("email: ") else: email = sys.argv[3] - pw = input("password: ") + pw = read_password() else: email, pw = sys.argv[3:5]