fix: auth not working bugfix

This commit is contained in:
Андрей Сумин
2025-03-01 18:23:20 +03:00
parent 656735649d
commit 0a35e3d2fa
+3 -1
View File
@@ -1,5 +1,6 @@
from http import HTTPStatus as status
from django.contrib.auth.hashers import check_password
from django.shortcuts import get_object_or_404
from ninja import Router
from ninja.errors import AuthenticationError
@@ -46,9 +47,10 @@ def sign_up(request, data: RegisterSchema):
)
def sign_in(request, data: LoginSchema):
user = User.objects.filter(email=data.email).first()
print(check_password(data.password, user.password))
if not user:
raise AuthenticationError
if not user.check_password(data.password):
if not check_password(data.password, user.password):
raise AuthenticationError
token = BearerAuth.generate_jwt(user)