mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-25 23:07:07 +03:00
keep password hashing on the event loop
This commit is contained in:
+2
-7
@@ -1,6 +1,5 @@
|
|||||||
"""Auth apis."""
|
"""Auth apis."""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import ipaddress
|
import ipaddress
|
||||||
@@ -1139,9 +1138,7 @@ async def update_password(
|
|||||||
content={"message": "Current password is required"},
|
content={"message": "Current password is required"},
|
||||||
status_code=400,
|
status_code=400,
|
||||||
)
|
)
|
||||||
if not await asyncio.to_thread(
|
if not verify_password(body.old_password, user.password_hash):
|
||||||
verify_password, body.old_password, user.password_hash
|
|
||||||
):
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={"message": "Current password is incorrect"},
|
content={"message": "Current password is incorrect"},
|
||||||
status_code=401,
|
status_code=401,
|
||||||
@@ -1155,9 +1152,7 @@ async def update_password(
|
|||||||
status_code=400,
|
status_code=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
password_hash = await asyncio.to_thread(
|
password_hash = hash_password(body.password, iterations=HASH_ITERATIONS)
|
||||||
hash_password, body.password, iterations=HASH_ITERATIONS
|
|
||||||
)
|
|
||||||
User.update(
|
User.update(
|
||||||
{
|
{
|
||||||
User.password_hash: password_hash,
|
User.password_hash: password_hash,
|
||||||
|
|||||||
Reference in New Issue
Block a user