mirror of
https://github.com/django/django.git
synced 2025-10-27 15:46:10 +00:00
[1.7.x] Fixed #22771 -- Fixed test.Client.logout when using custom auth backend.
Backport of 50b9313e0a from master
This commit is contained in:
committed by
Tim Graham
parent
d4305a15c1
commit
183e9d2029
20
tests/test_client_regress/auth_backends.py
Normal file
20
tests/test_client_regress/auth_backends.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from django.contrib.auth.backends import ModelBackend
|
||||
|
||||
from .models import CustomUser
|
||||
|
||||
|
||||
class CustomUserBackend(ModelBackend):
|
||||
|
||||
def authenticate(self, username=None, password=None):
|
||||
try:
|
||||
user = CustomUser.custom_objects.get_by_natural_key(username)
|
||||
if user.check_password(password):
|
||||
return user
|
||||
except CustomUser.DoesNotExist:
|
||||
return None
|
||||
|
||||
def get_user(self, user_id):
|
||||
try:
|
||||
return CustomUser.custom_objects.get(pk=user_id)
|
||||
except CustomUser.DoesNotExist:
|
||||
return None
|
||||
Reference in New Issue
Block a user