Commit c63ea01f by Petros Moisiadis

Support User model in Django 1.4 that has not a USERNAME_FIELD attribute

Support User model in Django 1.4 that has not a USERNAME_FIELD attribute.
parent 43b4ae75
......@@ -85,8 +85,13 @@ class BasicAuthentication(BaseAuthentication):
"""
Authenticate the userid and password against username and password.
"""
user_model = get_user_model()
if hasattr(user_model, 'USERNAME_FIELD'):
username_field = user_model.USERNAME_FIELD
else:
username_field = 'username'
credentials = {
get_user_model().USERNAME_FIELD: userid,
username_field: userid,
'password': password
}
user = authenticate(**credentials)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment