mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-11-30 13:20:40 +03:00
add scheduler middleware
This commit is contained in:
@@ -17,7 +17,9 @@ def compile_sql_or_scalar(func):
|
||||
async def wrapper(cls, db_session, name, compile_sql=False, *args, **kwargs):
|
||||
stmt = await func(cls, db_session, name, *args, **kwargs)
|
||||
if compile_sql:
|
||||
return stmt.compile(dialect=postgresql.dialect(), compile_kwargs={"literal_binds": True})
|
||||
return stmt.compile(
|
||||
dialect=postgresql.dialect(), compile_kwargs={"literal_binds": True}
|
||||
)
|
||||
result = await db_session.execute(stmt)
|
||||
return result.scalars().first()
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ class User(Base):
|
||||
@password.setter
|
||||
def password(self, password: SecretStr):
|
||||
_password_string = password.get_secret_value().encode("utf-8")
|
||||
self._password = bcrypt.hashpw(
|
||||
_password_string, bcrypt.gensalt()
|
||||
)
|
||||
self._password = bcrypt.hashpw(_password_string, bcrypt.gensalt())
|
||||
|
||||
def check_password(self, password: SecretStr):
|
||||
return bcrypt.checkpw(password.get_secret_value().encode("utf-8"), self._password)
|
||||
return bcrypt.checkpw(
|
||||
password.get_secret_value().encode("utf-8"), self._password
|
||||
)
|
||||
|
||||
@classmethod
|
||||
async def find(cls, database_session: AsyncSession, where_conditions: list[Any]):
|
||||
|
||||
Reference in New Issue
Block a user