Coverage for app/ddd/application/usecase/token/create_token_usecase.py: 100%
9 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-15 01:44 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-15 01:44 +0000
1from app.ddd.application.dto.token import CreateTokenInputDTO, CreateTokenOutputDTO
2from app.ddd.application.usecase.user.base_user_usecase import BaseUserUseCase
3from app.ddd.domain.model import Token, UserId
6class CreateTokenUseCase(BaseUserUseCase[CreateTokenInputDTO, CreateTokenOutputDTO]):
7 def execute(self, input_dto: CreateTokenInputDTO) -> CreateTokenOutputDTO:
8 user_id = UserId(root=input_dto.user_id)
9 user = self._uow.user_repository.find_by_id(user_id)
12 self.auth_service.verify_password(
13 plain_password = input_dto.user_password,
14 hashed_password = user.user_password
15 )
18 token: Token = self.token_factory.create(
19 user = user,
20 )
22 return CreateTokenOutputDTO.model_validate(token)