summaryrefslogtreecommitdiff
path: root/tests/auth_tests/models
diff options
context:
space:
mode:
authorlevental <levental@fh-brandenburg.de>2016-09-19 14:55:18 +0200
committerTim Graham <timograham@gmail.com>2016-09-27 11:59:00 -0400
commit617e36dc1ede2a311dfd03f18432b31cbfe4c0f7 (patch)
tree38fd43fc044ff923321b444c292686798dfb17bd /tests/auth_tests/models
parentf7e91cac689b28fc32ca52cdeac258ec0d58b4fc (diff)
Fixed #20705 -- Allowed using PasswordResetForm with user models with an email field not named 'email'.
Diffstat (limited to 'tests/auth_tests/models')
-rw-r--r--tests/auth_tests/models/with_custom_email_field.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auth_tests/models/with_custom_email_field.py b/tests/auth_tests/models/with_custom_email_field.py
new file mode 100644
index 0000000000..a98b02b8f1
--- /dev/null
+++ b/tests/auth_tests/models/with_custom_email_field.py
@@ -0,0 +1,23 @@
+from django.contrib.auth.base_user import AbstractBaseUser
+from django.contrib.auth.models import BaseUserManager
+from django.db import models
+
+
+class CustomEmailFieldUserManager(BaseUserManager):
+ def create_user(self, username, password, email):
+ user = self.model(username=username)
+ user.set_password(password)
+ user.email_address = email
+ user.save(using=self._db)
+ return user
+
+
+class CustomEmailField(AbstractBaseUser):
+ username = models.CharField(max_length=255)
+ password = models.CharField(max_length=255)
+ email_address = models.EmailField()
+ is_active = models.BooleanField(default=True)
+
+ EMAIL_FIELD = 'email_address'
+
+ objects = CustomEmailFieldUserManager()