fix invalid auth response

This commit is contained in:
bakatrouble 2025-08-01 09:42:53 +03:00
parent cf9aad9aee
commit 3723280e3d

View File

@ -69,7 +69,8 @@ def protected(wrapped):
) )
@validate(json=LoginRequest) @validate(json=LoginRequest)
async def login(_, body: LoginRequest): async def login(_, body: LoginRequest):
if not pbkdf2_sha256(10000, salt=b'salt').verify(body.password, api_auth.get(body.username)): hash = api_auth.get(body.username)
if not hash or not pbkdf2_sha256(10000, salt=b'salt').verify(body.password, hash):
return jsonr({'status': 'error', 'message': 'Invalid username or password'}) return jsonr({'status': 'error', 'message': 'Invalid username or password'})
return jsonr({ return jsonr({
'token': jwt.encode({}, api_secret, algorithm='HS256'), 'token': jwt.encode({}, api_secret, algorithm='HS256'),