# HG changeset patch # User Pascal Volk # Date 1393178753 0 # Node ID 66a5f9a405dafcbe74817427aa11c42004243541 # Parent ddcad86f738685fe9c86c62ab832a3fc16aee060 VMM/handler: Added method Handler.user_pwhash. diff -r ddcad86f7386 -r 66a5f9a405da VirtualMailManager/handler.py --- a/VirtualMailManager/handler.py Sun Feb 23 18:00:35 2014 +0000 +++ b/VirtualMailManager/handler.py Sun Feb 23 18:05:53 2014 +0000 @@ -40,6 +40,7 @@ from VirtualMailManager.errors import \ DomainError, NotRootError, PermissionError, VMMError from VirtualMailManager.mailbox import new as new_mailbox +from VirtualMailManager.password import extract_scheme, verify_scheme from VirtualMailManager.quotalimit import QuotaLimit from VirtualMailManager.relocated import Relocated from VirtualMailManager.serviceset import ServiceSet, SERVICES @@ -765,6 +766,20 @@ acc.address, NO_SUCH_ACCOUNT) acc.update_password(password, scheme) + def user_pwhash(self, emailaddress, pwhash): + """Wrapper for Account.modify('pwhash', ...)""" + scheme = extract_scheme(pwhash) + if not scheme: + raise VMMError(_('Missing {SCHEME} prefix from password hash.'), + INVALID_ARGUMENT) + else: + scheme, encoding = verify_scheme(scheme) # or die … + acc = self._get_account(emailaddress) + if not acc: + raise VMMError(_("The account '%s' does not exist.") % + acc.address, NO_SUCH_ACCOUNT) + acc.modify('pwhash', pwhash) + def user_name(self, emailaddress, name): """Wrapper for Account.modify('name', ...).""" acc = self._get_account(emailaddress)