Browse Source

Grab users with mail via get_by_email

Rafał Pitoń 11 years ago
parent
commit
2f3cfa75b4
3 changed files with 5 additions and 7 deletions
  1. 2 3
      misago/apps/activation/forms.py
  2. 2 3
      misago/apps/resetpswd/forms.py
  3. 1 1
      misago/models/usermodel.py

+ 2 - 3
misago/apps/activation/forms.py

@@ -15,9 +15,8 @@ class UserSendActivationMailForm(Form):
 
     def clean_email(self):
         try:
-            email = self.cleaned_data['email'].lower()
-            email_hash = hashlib.md5(email).hexdigest()
-            self.found_user = User.objects.get(email_hash=email_hash)
+            self.found_user = User.objects.get_by_email(
+                self.cleaned_data['email'])
         except User.DoesNotExist:
             raise ValidationError(_("There is no user with such e-mail address."))
         return email

+ 2 - 3
misago/apps/resetpswd/forms.py

@@ -15,9 +15,8 @@ class UserResetPasswordForm(Form):
 
     def clean_email(self):
         try:
-            email = self.cleaned_data['email'].lower()
-            email_hash = hashlib.md5(email).hexdigest()
-            self.found_user = User.objects.get(email_hash=email_hash)
+            self.found_user = User.objects.get_by_email(
+                self.cleaned_data['email'])
         except User.DoesNotExist:
             raise ValidationError(_("There is no user with such e-mail address."))
         return email

+ 1 - 1
misago/models/usermodel.py

@@ -99,7 +99,7 @@ class UserManager(models.Manager):
         return new_user
 
     def get_by_email(self, email):
-        return self.get(email_hash=hashlib.md5(email).hexdigest())
+        return self.get(email_hash=hashlib.md5(email.lower()).hexdigest())
 
     def filter_stats(self, start, end):
         return self.filter(join_date__gte=start).filter(join_date__lte=end)