academon/core/backends/reportmonster.py

22 lines
700 B
Python
Raw Normal View History

2022-08-08 09:43:31 +00:00
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth import get_user_model
from django.contrib import messages
from django.conf import settings
from bcrypt import checkpw
class ReportMonsterBackend(ModelBackend):
def authenticate(self, request, username: str = None, password:str = None):
self.request = request
2022-08-08 15:18:39 +00:00
monster = settings.MONSTERCONFIG
loginvessel = filter(lambda x: x.name = settings.LOGIN_VESSEL, monster.vessels)[0]
2022-08-08 09:43:31 +00:00
2022-08-08 15:18:39 +00:00
2022-08-08 09:43:31 +00:00
if checkpw(password.encode(), userdata.content["password"].encode()):
user, _ = get_user_model().objects.get_or_create(email=username)
user.save()
return user