#26986: `force_login` requires `user.is_active` in 1.10
--------------------------------------+------------------------------------
Reporter: Tordek | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by Tordek):
I have a custom user model that is valid when its `validation_date` is
set.
Simplified:
{{{
class MyUser(AbstractBaseUser, PermissionsMixin):
email = models.CharField(max_length=255, unique=True)
validation_date = models.DateTimeField(null=True)
USERNAME_FIELD = 'email'
@property
def is_active(self):
return self.validation_date is not None
}}}
I have a test on a view that requires login, like
{{{
def test_user_must_be_logged_in(self):
response = self.client.get("some.url")
self.assertRedirects(response, "/login/?next=some.url")
self.client.force_login(self.user)
response = self.client.get("some.url")
self.assertEqual(200, response.status_code)
}}}
This test worked in 1.9 but is broken in 1.10; the user is not logged in
unless I assign a value to `validation_date` and save (i.e., unless the
user's `is_active` returns `True`).
If you require a complete example, just ask :)
--
Ticket URL: <https://code.djangoproject.com/ticket/26986#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.8d15de0da0b7ce6dd211cfd0eca3c0bf%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.