add simple user admin and hash password

This commit is contained in:
Timur
2025-03-01 17:40:08 +03:00
parent 9a5a924333
commit 656735649d
6 changed files with 25 additions and 2 deletions
+2 -1
View File
@@ -27,6 +27,7 @@ router = Router(tags=["user"])
)
def sign_up(request, data: RegisterSchema):
user = User(**data.dict())
user.password = user.make_password()
user.full_clean()
user.save()
@@ -47,7 +48,7 @@ def sign_in(request, data: LoginSchema):
user = User.objects.filter(email=data.email).first()
if not user:
raise AuthenticationError
if user.password != data.password:
if not user.check_password(data.password):
raise AuthenticationError
token = BearerAuth.generate_jwt(user)