diff options
| author | Barry Warsaw | 2015-01-04 20:20:33 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2015-01-04 20:20:33 -0500 |
| commit | 4a612db8e89afed74173b93f3b64fa567b8417a3 (patch) | |
| tree | 81a687d113079a25f93279f35c7eee2aa2572510 /src/mailman/rest/users.py | |
| parent | 84af79988a4e916604cba31843778206efb7d1b8 (diff) | |
| parent | de181c1a40965a3a7deedd56a034a946f45b6984 (diff) | |
| download | mailman-4a612db8e89afed74173b93f3b64fa567b8417a3.tar.gz mailman-4a612db8e89afed74173b93f3b64fa567b8417a3.tar.zst mailman-4a612db8e89afed74173b93f3b64fa567b8417a3.zip | |
Diffstat (limited to 'src/mailman/rest/users.py')
| -rw-r--r-- | src/mailman/rest/users.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/mailman/rest/users.py b/src/mailman/rest/users.py index 7ab1d6818..175c1f76c 100644 --- a/src/mailman/rest/users.py +++ b/src/mailman/rest/users.py @@ -17,21 +17,15 @@ """REST for users.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AUser', + 'AddressUser', 'AllUsers', 'Login', ] from lazr.config import as_boolean -from passlib.utils import generate_password as generate -from uuid import UUID -from zope.component import getUtility - from mailman.config import config from mailman.core.errors import ( ReadOnlyPATCHRequestError, UnknownPATCHRequestError) @@ -44,8 +38,12 @@ from mailman.rest.helpers import ( path_to) from mailman.rest.preferences import Preferences from mailman.rest.validator import PatchValidator, Validator +from passlib.utils import generate_password as generate +from uuid import UUID +from zope.component import getUtility + # Attributes of a user which can be changed via the REST API. class PasswordEncrypterGetterSetter(GetterSetter): def __init__(self): @@ -60,19 +58,20 @@ class PasswordEncrypterGetterSetter(GetterSetter): ATTRIBUTES = dict( - display_name=GetterSetter(unicode), + display_name=GetterSetter(str), cleartext_password=PasswordEncrypterGetterSetter(), ) CREATION_FIELDS = dict( - email=unicode, - display_name=unicode, - password=unicode, + email=str, + display_name=str, + password=str, _optional=('display_name', 'password'), ) + def create_user(arguments, response): """Create a new user.""" # We can't pass the 'password' argument to the user creation method, so @@ -83,7 +82,7 @@ def create_user(arguments, response): user = getUtility(IUserManager).create_user(**arguments) except ExistingAddressError as error: bad_request( - response, b'Address already exists: {}'.format(error.address)) + response, 'Address already exists: {}'.format(error.address)) return None if password is None: # This will have to be reset since it cannot be retrieved. @@ -360,7 +359,7 @@ class Login: # We do not want to encrypt the plaintext password given in the POST # data. That would hash the password, but we need to have the # plaintext in order to pass into passlib. - validator = Validator(cleartext_password=GetterSetter(unicode)) + validator = Validator(cleartext_password=GetterSetter(str)) try: values = validator(request) except ValueError as error: |
