add user password hasher and depebdency
This commit is contained in:
@@ -30,8 +30,7 @@ def create_engine(
|
||||
def create_session_maker(
|
||||
engine: Annotated[AsyncEngine, Depends(Stub(AsyncEngine))],
|
||||
) -> async_sessionmaker[AsyncSession]:
|
||||
maker = async_sessionmaker(engine, expire_on_commit=False)
|
||||
return maker
|
||||
return async_sessionmaker(engine, expire_on_commit=False)
|
||||
|
||||
|
||||
async def new_session(
|
||||
|
6
api/infrastructure/dependencies/protocols.py
Normal file
6
api/infrastructure/dependencies/protocols.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from api.application.protocols.password_hasher import PasswordHasher
|
||||
from api.infrastructure.security.password_hasher import Pbkdf2PasswordHasher
|
||||
|
||||
|
||||
def get_password_hasher() -> PasswordHasher:
|
||||
return Pbkdf2PasswordHasher()
|
@@ -3,13 +3,15 @@ from typing import Annotated
|
||||
from fastapi import Depends
|
||||
|
||||
from api.application.abstractions.uow import UnitOfWork
|
||||
from api.application.usecase.create_user import CreateUser
|
||||
from api.application.protocols.password_hasher import PasswordHasher
|
||||
from api.application.usecase.user.create_user import CreateUser
|
||||
from api.domain.user.repository import UserRepository
|
||||
from api.infrastructure.dependencies.stub import Stub
|
||||
|
||||
|
||||
def provide_create_user(
|
||||
user_repository: Annotated[UserRepository, Depends(Stub(UserRepository))],
|
||||
uow: Annotated[UnitOfWork, Depends()],
|
||||
uow: Annotated[UnitOfWork, Depends(Stub(UnitOfWork))],
|
||||
password_hasher: Annotated[PasswordHasher, Depends(Stub(PasswordHasher))],
|
||||
) -> CreateUser:
|
||||
return CreateUser(uow=uow, user_repository=user_repository)
|
||||
return CreateUser(uow=uow, user_repository=user_repository, password_hasher=password_hasher)
|
||||
|
Reference in New Issue
Block a user