mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 02:47:10 +00:00
fix: fixed bug in auth and me
This commit is contained in:
@@ -4,8 +4,8 @@ from typing import Any
|
|||||||
import jwt
|
import jwt
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
|
from ninja.errors import AuthenticationError
|
||||||
from ninja.security import HttpBearer
|
from ninja.security import HttpBearer
|
||||||
from redis.exceptions import AuthorizationError
|
|
||||||
|
|
||||||
from apps.user.models import User
|
from apps.user.models import User
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ class BearerAuth(HttpBearer):
|
|||||||
if data["exp"] < datetime.datetime.now().timestamp():
|
if data["exp"] < datetime.datetime.now().timestamp():
|
||||||
return None
|
return None
|
||||||
except Exception:
|
except Exception:
|
||||||
raise AuthorizationError
|
raise AuthenticationError
|
||||||
|
|
||||||
user = User.objects.get(id=data["id"])
|
user = User.objects.get(id=data["id"])
|
||||||
return user
|
return user
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ 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 check_password(data.password, user.password):
|
if not check_password(data.password, user.password):
|
||||||
|
|||||||
Reference in New Issue
Block a user