summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/cli')
-rw-r--r--src/leap/bitmask/cli/user.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/leap/bitmask/cli/user.py b/src/leap/bitmask/cli/user.py
index 9ce4dc6a..1c4757e1 100644
--- a/src/leap/bitmask/cli/user.py
+++ b/src/leap/bitmask/cli/user.py
@@ -35,6 +35,7 @@ SUBCOMMANDS:
create Registers new user, if possible
auth Logs in against the provider
logout Ends any active session with the provider
+ update Update user password
active Shows the active user, if any
'''.format(name=command.appname)
@@ -47,7 +48,7 @@ SUBCOMMANDS:
def create(self, raw_args):
username = self.username(raw_args)
- passwd = getpass.getpass()
+ passwd = self.getpass_twice()
self.data += ['create', username, passwd, 'true']
return self._send(printer=command.default_dict_printer)
@@ -62,6 +63,13 @@ SUBCOMMANDS:
self.data += ['logout', username]
return self._send(printer=command.default_dict_printer)
+ def update(self, raw_args):
+ username = self.username(raw_args)
+ current_passwd = getpass.getpass('Current password: ')
+ new_passwd = self.getpass_twice('New password: ')
+ self.data += ['update', username, current_passwd, new_passwd]
+ return self._send(printer=command.default_dict_printer)
+
def username(self, raw_args):
args = tuple([command.appname] + sys.argv[1:3])
parser = argparse.ArgumentParser(
@@ -78,3 +86,13 @@ SUBCOMMANDS:
self._error("Username ID must be in the form <user@example.org>")
return username
+
+ def getpass_twice(self, prompt='Password: '):
+ while True:
+ passwd1 = getpass.getpass(prompt)
+ passwd2 = getpass.getpass('Retype the password: ')
+ if passwd1 == passwd2:
+ return passwd1
+ else:
+ print "The passwords do not match, try again."
+ print ""