Guest User

Untitled

a guest
May 16th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. # settings.py
  2. ...
  3. AUTHENTICATION_BACKENDS = ('project.auth_backend.CustomBackend',)
  4. ...
  5. # auth_backend.py
  6. from django.contrib.auth.backends import ModelBackend
  7. from django.contrib.auth.models import User
  8.  
  9. class CustomBackend(ModelBackend):
  10. def authenticate(self, username=None, password=None):
  11. try:
  12. user = User.objects.get(username=username)
  13. if user.check_password(password):
  14. [b]# do some voodoo[/b]
  15. return user
  16. except User.DoesNotExist:
  17. return None
Add Comment
Please, Sign In to add comment