summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/cli/user.py
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2016-09-27 19:28:28 -0500
committerRuben Pollan <meskio@sindominio.net>2016-09-28 17:23:37 -0500
commit2fc85ad7d109ca4304d1fb1515b7087a1bb2ae3e (patch)
treef3627d5b9fd613dad05aa416df7d445fde02e0ae /src/leap/bitmask/cli/user.py
parent1aa1ffde9613435fe95434ead4909ea081d0c3c9 (diff)
[feature]Add change password command
- Resolves: #8487
Diffstat (limited to 'src/leap/bitmask/cli/user.py')
-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 ""