VMM/cli/handler: Improved CliHandler.user_password. v0.7.x
authorPascal Volk <user@localhost.localdomain.org>
Sat, 15 Feb 2014 21:48:40 +0000
branchv0.7.x
changeset 729 26a6231b9c6a
parent 728 69eb7a65d8a4
child 730 d3a246067e8f
VMM/cli/handler: Improved CliHandler.user_password. When possible check the given password scheme before prompting for the password.
VirtualMailManager/cli/handler.py
--- a/VirtualMailManager/cli/handler.py	Sat Feb 15 19:00:40 2014 +0000
+++ b/VirtualMailManager/cli/handler.py	Sat Feb 15 21:48:40 2014 +0000
@@ -16,7 +16,7 @@
 from VirtualMailManager.cli.config import CliConfig as Cfg
 from VirtualMailManager.constants import ACCOUNT_EXISTS, INVALID_SECTION, \
      NO_SUCH_ACCOUNT, TYPE_ACCOUNT
-from VirtualMailManager.password import randompw
+from VirtualMailManager.password import randompw, verify_scheme
 
 _ = lambda msg: msg
 
@@ -94,6 +94,10 @@
         if not acc:
             raise VMMError(_("The account '%s' does not exist.") %
                            acc.address, NO_SUCH_ACCOUNT)
+        if scheme:
+            scheme, encoding = verify_scheme(scheme)
+            if encoding:
+                scheme = '%s.%s' % (scheme, encoding)
         if not isinstance(password, str) or not password:
             password = read_pass()
         acc.update_password(password, scheme)