Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AUTHENTICATION_BACKENDS = ('login_app.backends.LoginBackend',
- 'django.contrib.auth.backends.ModelBackend')
- # Password validation
- # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
- AUTH_PASSWORD_VALIDATORS = [
- {
- 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
- },
- ]
- def authenticate(self, email=None, password=None):
- try:
- user = User.objects.get(email=email)
- if password == user.password:
- return user
- else:
- return None
- except User.DoesNotExist:
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement