rollback-тесты на urllib из-за нестабильности httpx через docker-proxy на win
This commit is contained in:
+5
-3
@@ -16,7 +16,7 @@ SESSION_TTL = int(os.getenv("SESSION_TTL_SECONDS", "3600"))
|
||||
|
||||
def _prehash(password: str) -> bytes:
|
||||
# bcrypt работает с ≤72 байт, SHA-256 даёт 32 байта и снимает ограничение
|
||||
return hashlib.sha256(password.encode("utf-8")).digest()
|
||||
return hashlib.sha256(password.encode("utf-8")).hexdigest().encode("ascii")
|
||||
|
||||
|
||||
def hash_password(password: str) -> str:
|
||||
@@ -72,7 +72,9 @@ async def revoke_current_session(authorization: str, db: AsyncSession) -> None:
|
||||
if not authorization or not authorization.startswith("Bearer "):
|
||||
raise _unauthorized_bearer()
|
||||
token = authorization[7:]
|
||||
await db.execute(
|
||||
result = await db.execute(
|
||||
delete(SessionRow).where(SessionRow.token_hash == hash_token(token))
|
||||
)
|
||||
await db.commit()
|
||||
await db.commit()
|
||||
if result.rowcount == 0:
|
||||
raise _unauthorized_bearer()
|
||||
Reference in New Issue
Block a user