mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
21 lines
622 B
Python
21 lines
622 B
Python
from django.contrib.auth import get_user_model
|
|
from django.contrib.auth.backends import ModelBackend
|
|
from Auth.models import Profile
|
|
from N3wtSchool import bdd
|
|
|
|
class EmailBackend(ModelBackend):
|
|
def authenticate(self, request, username=None, password=None, **kwargs):
|
|
|
|
if username is None:
|
|
username = kwargs.get(Profile.USERNAME_FIELD)
|
|
|
|
try:
|
|
user = Profile.objects.get(email=username)
|
|
|
|
# Vérifie le mot de passe de l'utilisateur
|
|
if user.check_password(password):
|
|
return user
|
|
except Profile.DoesNotExist:
|
|
return None
|
|
|