Fix auth to use get_user_document #527
				
					
				
			This commit is contained in:
		| @@ -8,6 +8,11 @@ from django.contrib import auth | |||||||
| from django.contrib.auth.models import AnonymousUser | from django.contrib.auth.models import AnonymousUser | ||||||
| from django.utils.translation import ugettext_lazy as _ | from django.utils.translation import ugettext_lazy as _ | ||||||
|  |  | ||||||
|  | from .utils import datetime_now | ||||||
|  | from .mongo_auth import get_user_document | ||||||
|  |  | ||||||
|  | REDIRECT_FIELD_NAME = 'next' | ||||||
|  |  | ||||||
| try: | try: | ||||||
|     from django.contrib.auth.hashers import check_password, make_password |     from django.contrib.auth.hashers import check_password, make_password | ||||||
| except ImportError: | except ImportError: | ||||||
| @@ -33,10 +38,6 @@ except ImportError: | |||||||
|         hash = get_hexdigest(algo, salt, raw_password) |         hash = get_hexdigest(algo, salt, raw_password) | ||||||
|         return '%s$%s$%s' % (algo, salt, hash) |         return '%s$%s$%s' % (algo, salt, hash) | ||||||
|  |  | ||||||
| from .utils import datetime_now |  | ||||||
|  |  | ||||||
| REDIRECT_FIELD_NAME = 'next' |  | ||||||
|  |  | ||||||
|  |  | ||||||
| class ContentType(Document): | class ContentType(Document): | ||||||
|     name = StringField(max_length=100) |     name = StringField(max_length=100) | ||||||
| @@ -383,7 +384,7 @@ class MongoEngineBackend(object): | |||||||
|     supports_inactive_user = False |     supports_inactive_user = False | ||||||
|  |  | ||||||
|     def authenticate(self, username=None, password=None): |     def authenticate(self, username=None, password=None): | ||||||
|         user = User.objects(username=username).first() |         user = get_user_document().objects(username=username).first() | ||||||
|         if user: |         if user: | ||||||
|             if password and user.check_password(password): |             if password and user.check_password(password): | ||||||
|                 backend = auth.get_backends()[0] |                 backend = auth.get_backends()[0] | ||||||
| @@ -392,7 +393,7 @@ class MongoEngineBackend(object): | |||||||
|         return None |         return None | ||||||
|  |  | ||||||
|     def get_user(self, user_id): |     def get_user(self, user_id): | ||||||
|         return User.objects.with_id(user_id) |         return get_user_document().objects.with_id(user_id) | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_user(userid): | def get_user(userid): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user