Slightly reworked imports in contrib.auth.__init__
This commit is contained in:
parent
dc43fbc2f2
commit
710c59bf9b
|
@ -1,9 +1,11 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.contrib.auth.signals import user_logged_in, user_logged_out, user_login_failed
|
from django.conf import settings
|
||||||
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
|
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
|
||||||
from django.utils.module_loading import import_by_path
|
from django.utils.module_loading import import_by_path
|
||||||
|
|
||||||
|
from .signals import user_logged_in, user_logged_out, user_login_failed
|
||||||
|
|
||||||
SESSION_KEY = '_auth_user_id'
|
SESSION_KEY = '_auth_user_id'
|
||||||
BACKEND_SESSION_KEY = '_auth_user_backend'
|
BACKEND_SESSION_KEY = '_auth_user_backend'
|
||||||
REDIRECT_FIELD_NAME = 'next'
|
REDIRECT_FIELD_NAME = 'next'
|
||||||
|
@ -14,7 +16,6 @@ def load_backend(path):
|
||||||
|
|
||||||
|
|
||||||
def get_backends():
|
def get_backends():
|
||||||
from django.conf import settings
|
|
||||||
backends = []
|
backends = []
|
||||||
for backend_path in settings.AUTHENTICATION_BACKENDS:
|
for backend_path in settings.AUTHENTICATION_BACKENDS:
|
||||||
backends.append(load_backend(backend_path))
|
backends.append(load_backend(backend_path))
|
||||||
|
@ -106,7 +107,6 @@ def logout(request):
|
||||||
|
|
||||||
def get_user_model():
|
def get_user_model():
|
||||||
"Return the User model that is active in this project"
|
"Return the User model that is active in this project"
|
||||||
from django.conf import settings
|
|
||||||
from django.db.models import get_model
|
from django.db.models import get_model
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -120,8 +120,7 @@ def get_user_model():
|
||||||
|
|
||||||
|
|
||||||
def get_user(request):
|
def get_user(request):
|
||||||
from django.conf import settings
|
from .models import AnonymousUser
|
||||||
from django.contrib.auth.models import AnonymousUser
|
|
||||||
try:
|
try:
|
||||||
user_id = request.session[SESSION_KEY]
|
user_id = request.session[SESSION_KEY]
|
||||||
backend_path = request.session[BACKEND_SESSION_KEY]
|
backend_path = request.session[BACKEND_SESSION_KEY]
|
||||||
|
|
Loading…
Reference in New Issue