Allow superusers to login from any organization.

This commit is contained in:
Roberto Rosario
2016-06-24 03:26:24 -04:00
parent 09e375654d
commit dd28e3dc09

View File

@@ -14,6 +14,12 @@ class UsernameModelBackend(ModelBackend):
user = UserModel.on_organization.get(username=username)
if user.check_password(password):
return user
except UserModel.DoesNotExist:
# Check for superadmins, they can login from any organization.
try:
user = UserModel.objects.filter(is_superuser=True).get(username=username)
if user.check_password(password):
return user
except UserModel.DoesNotExist:
# Run the default password hasher once to reduce the timing
# difference between an existing and a non-existing user (#20760).