From 4d109a68579d18e5e8c59376bcc5bd09668bce13 Mon Sep 17 00:00:00 2001 From: Arthur Vuillard Date: Thu, 11 May 2017 18:19:33 +0200 Subject: [PATCH] fix a test in python3 --- modoboa/core/models.py | 5 +++-- modoboa/core/password_hashers/base.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modoboa/core/models.py b/modoboa/core/models.py index 928c0c873..bfd3a173b 100644 --- a/modoboa/core/models.py +++ b/modoboa/core/models.py @@ -9,7 +9,7 @@ from django.core.urlresolvers import reverse from django.db import models from django.utils import timezone from django.utils.encoding import ( - python_2_unicode_compatible, smart_bytes, smart_text) + python_2_unicode_compatible, smart_bytes, smart_text, force_str) from django.utils.functional import cached_property from django.utils.translation import ugettext as _, ugettext_lazy @@ -154,7 +154,7 @@ class User(PermissionsMixin): match = self.password_expr.match(self.password) if match is None: return False - raw_value = smart_bytes(raw_value) + raw_value = force_str(raw_value) scheme = match.group(1) val2 = match.group(2) hasher = get_password_hasher(scheme) @@ -425,6 +425,7 @@ class User(PermissionsMixin): row += result[1] csvwriter.writerow(row) + reversion.register(User) diff --git a/modoboa/core/password_hashers/base.py b/modoboa/core/password_hashers/base.py index 73c4b237a..586ff6efd 100644 --- a/modoboa/core/password_hashers/base.py +++ b/modoboa/core/password_hashers/base.py @@ -13,6 +13,7 @@ from random import Random import string from django.utils.crypto import constant_time_compare +from django.utils.encoding import force_text class PasswordHasher(object): @@ -35,7 +36,7 @@ class PasswordHasher(object): """ if self._target == 'ldap': return base64.b64encode(pwhash) - return pwhash + return force_text(pwhash) def encrypt(self, clearvalue): """Encrypt a password.