UserModel -> User
This commit is contained in:
parent
ecee55b343
commit
0dfc8f6aea
2 changed files with 6 additions and 8 deletions
|
@ -3,7 +3,7 @@ from authens.backends import ENSCASBackend
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.contrib.auth.backends import ModelBackend
|
from django.contrib.auth.backends import ModelBackend
|
||||||
|
|
||||||
UserModel = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class CASBackend(ENSCASBackend):
|
class CASBackend(ENSCASBackend):
|
||||||
|
@ -16,9 +16,7 @@ class CASBackend(ENSCASBackend):
|
||||||
email = attributes.get("email")
|
email = attributes.get("email")
|
||||||
name = attributes.get("name")
|
name = attributes.get("name")
|
||||||
|
|
||||||
return UserModel.objects.create_user(
|
return User.objects.create_user(username=username, email=email, full_name=name)
|
||||||
username=username, email=email, full_name=name
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class PwdBackend(ModelBackend):
|
class PwdBackend(ModelBackend):
|
||||||
|
@ -45,10 +43,10 @@ class ElectionBackend(ModelBackend):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user = UserModel.objects.get(
|
user = User.objects.get(
|
||||||
username=f"{election_id}__{login}", election=election_id
|
username=f"{election_id}__{login}", election=election_id
|
||||||
)
|
)
|
||||||
except UserModel.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if user.check_password(password):
|
if user.check_password(password):
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.contrib.auth import get_user_model
|
||||||
from django.core.validators import validate_email
|
from django.core.validators import validate_email
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
UserModel = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class ElectionAuthForm(forms.Form):
|
class ElectionAuthForm(forms.Form):
|
||||||
|
@ -80,5 +80,5 @@ class PwdUserForm(forms.ModelForm):
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = UserModel
|
model = User
|
||||||
fields = ["username", "full_name", "email"]
|
fields = ["username", "full_name", "email"]
|
||||||
|
|
Loading…
Reference in a new issue