mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 19:07:10 +00:00
fix: auth not working bugfix
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from http import HTTPStatus as status
|
from http import HTTPStatus as status
|
||||||
|
|
||||||
|
from django.contrib.auth.hashers import check_password
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from ninja import Router
|
from ninja import Router
|
||||||
from ninja.errors import AuthenticationError
|
from ninja.errors import AuthenticationError
|
||||||
@@ -46,9 +47,10 @@ def sign_up(request, data: RegisterSchema):
|
|||||||
)
|
)
|
||||||
def sign_in(request, data: LoginSchema):
|
def sign_in(request, data: LoginSchema):
|
||||||
user = User.objects.filter(email=data.email).first()
|
user = User.objects.filter(email=data.email).first()
|
||||||
|
print(check_password(data.password, user.password))
|
||||||
if not user:
|
if not user:
|
||||||
raise AuthenticationError
|
raise AuthenticationError
|
||||||
if not user.check_password(data.password):
|
if not check_password(data.password, user.password):
|
||||||
raise AuthenticationError
|
raise AuthenticationError
|
||||||
|
|
||||||
token = BearerAuth.generate_jwt(user)
|
token = BearerAuth.generate_jwt(user)
|
||||||
|
|||||||
Reference in New Issue
Block a user