Login as Any Site user

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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
    backend = get_backends()[0]
    from django.contrib.auth.models import User
    user = User.objects.get(email=email)
    user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__)
    from django.contrib.auth import login as django_login
    django_login(request, user)
    #set_any_extra_session_variables(request)

More like this

  1. All Imports Checker by madhav.bnk 3 years, 6 months ago
  2. Mask sensitive POST fields in error e-mails by derivin 5 years, 3 months ago
  3. LoginAsForm - Login as any User without a password by johnboxall 4 years ago
  4. testdata tag for templates by showell 4 years, 1 month ago
  5. Update only selected model fields by jcrocholl 5 years, 7 months ago

Comments

leosh (on November 30, 2009):

Check out an 'su' view: http://copiousfreetime.blogspot.com/2006/12/django-su.html

It does the same thing as this snippet but with wrapping and explanations.

#

KomarovPetr26 (on December 2, 2011):

ВИП-сваха для брака с богачом

#

ZaharovMatvej21 (on January 7, 2012):

прокат, аренда аттракционов Киев, большой выбор

#

(Forgotten your password?)