This commit is contained in:
+11
-1
@@ -1,7 +1,7 @@
|
||||
from collections.abc import Collection
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, update
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.models.user import User
|
||||
@@ -45,3 +45,13 @@ async def get_existing_user_ids(
|
||||
result = await session.execute(stmt)
|
||||
existing_ids = set(result.scalars().all())
|
||||
return existing_ids
|
||||
|
||||
|
||||
async def replace_password_hash(
|
||||
session: AsyncSession, user_id: UUID, previous: str, replacement: str
|
||||
) -> None:
|
||||
await session.execute(
|
||||
update(User)
|
||||
.where(User.id == user_id, User.password_hash == previous)
|
||||
.values(password_hash=replacement)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user