-
-
Save albsen/343381 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.admin.views.decorators import staff_member_required | |
@staff_member_required | |
def login_using_email(request, email): | |
'''DONT EVER USE this method for normal purposes. This is only there, for debugging specific problems related to users''' | |
from django.contrib.auth import get_backends | |
from django.contrib.auth import login as django_login | |
from django.contrib.auth.models import User | |
backend = get_backends()[0] | |
user = User.objects.get(email=email) | |
user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__) | |
django_login(request, user) | |
#set_any_extra_session_variables(request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment