Rafał Pitoń 11 years ago
parent
commit
caf895602b
2 changed files with 5 additions and 5 deletions
  1. 1 1
      misago/apps/usercp/credentials/forms.py
  2. 4 4
      misago/models/usermodel.py

+ 1 - 1
misago/apps/usercp/credentials/forms.py

@@ -19,7 +19,7 @@ class CredentialsChangeForm(Form):
 
     def clean_new_email(self):
         if self.cleaned_data['new_email']:
-            new_hash = hashlib.md5(self.cleaned_data['new_email'].lower()).hexdigest()
+            new_hash = hashlib.md5(self.cleaned_data['new_email'].lower().encode('utf-8')).hexdigest()
             if new_hash == self.request.user.email_hash:
                 raise ValidationError(_("New e-mail is same as your current e-mail."))
             try:

+ 4 - 4
misago/models/usermodel.py

@@ -100,7 +100,7 @@ class UserManager(models.Manager):
         return new_user
 
     def get_by_email(self, email):
-        return self.get(email_hash=hashlib.md5(email.lower()).hexdigest())
+        return self.get(email_hash=hashlib.md5(email.lower().encode('utf-8')).hexdigest())
 
     def filter_stats(self, start, end):
         return self.filter(join_date__gte=start).filter(join_date__lte=end)
@@ -350,7 +350,7 @@ class User(models.Model):
 
     def set_email(self, email):
         self.email = email.strip().lower()
-        self.email_hash = hashlib.md5(self.email).hexdigest()
+        self.email_hash = hashlib.md5(self.email.encode('utf-8')).hexdigest()
 
     def set_password(self, raw_password):
         self.password_date = tz_util.now()
@@ -469,7 +469,7 @@ class User(models.Model):
                 and not '?' in settings.GRAVATAR_DEFAULT):
             gravatar_default = '&d=%s' % settings.GRAVATAR_DEFAULT
 
-        return 'http://www.gravatar.com/avatar/%s?s=%s%s' % (hashlib.md5(self.email).hexdigest(), image_size, gravatar_default)
+        return 'http://www.gravatar.com/avatar/%s?s=%s%s' % (hashlib.md5(self.email.encode('utf-8')).hexdigest(), image_size, gravatar_default)
 
     def get_ranking(self):
         if not self.ranking:
@@ -722,4 +722,4 @@ def sync_user_handler(sender, **kwargs):
     sender.following = sender.follows.count()
     sender.followers = sender.follows_set.count()
 
-sync_user_profile.connect(sync_user_handler, dispatch_uid="sync_user_follows")
+sync_user_profile.connect(sync_user_handler, dispatch_uid="sync_user_follows")