Skip to content

♻️ auth 패키지 구현체 및 DI 도입, email 패키지 분리#42

Merged
Yeonu-Kim merged 4 commits into
mainfrom
refactor/#39
Jun 22, 2026
Merged

♻️ auth 패키지 구현체 및 DI 도입, email 패키지 분리#42
Yeonu-Kim merged 4 commits into
mainfrom
refactor/#39

Conversation

@Yeonu-Kim

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread app/auth/models.py
Comment on lines +11 to +12
if TYPE_CHECKING:
from app.models.deposit import Deposit

@Yeonu-Kim Yeonu-Kim Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deposit 안 쓰니까 제거해야 됨
-> 별도 issue로 뽑아두기

Comment on lines +35 to +61
class EmailVerificationRepositoryImpl(EmailVerificationRepository):
def __init__(self, db: AsyncSession) -> None:
self.db = db

async def save(self, verification: EmailVerification) -> None:
self.db.add(verification)
await self.db.commit()

async def find_latest_unverified(
self, email: str, code: str
) -> EmailVerification | None:
return cast(
EmailVerification | None,
await self.db.scalar(
select(EmailVerification)
.where(
EmailVerification.email == email,
EmailVerification.code == code,
EmailVerification.is_verified.is_(False),
EmailVerification.expires_at > datetime.now(UTC),
)
.order_by(EmailVerification.created_at.desc())
),
)

async def update(self, verification: EmailVerification) -> None:
await self.db.commit()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

인증코드 저장 로직은 별도 repo로 분리 (User 생성하는 거랑 로직상으로 차이가 있음. 한방에 묶어서 관리하기보다는 별도로 분리했을 때 추후 디버깅할 때 여기만 보면 되니까 유리할 듯

Comment thread app/email/service.py Outdated
Comment on lines +4 to +18
class EmailSender(ABC):
@abstractmethod
async def send_verification(self, to: str, code: str) -> None: ...

@abstractmethod
async def send_temp_password(self, to: str, temp_password: str) -> None: ...

@abstractmethod
async def send_reward(
self,
to: str,
event_title: str,
reward_wei: int,
wallet_balance_wei: int,
) -> None: ...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email-service에서는 정말 전송만 담당함.

@Yeonu-Kim Yeonu-Kim Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send-reward도 사실 여기에 들어가는 게 아니라 blokchain 관련 패키지에서 메세지를 제공하는 대로 전송하는 게 맞지 않을까?
-> 수정해서 커밋 완료

created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now()
)
from app.auth.models import EmailVerification as EmailVerification # noqa: F401

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 파일 때문에 임시로 이렇게 불필요한 코드를 넣어둠. 리팩토링 완료하면 삭제해도 됨.

Comment thread app/services/blockchain.py Outdated

from app.core.config import settings
from app.core.email import send_reward_email
from app.email.service_impl import send_reward_email

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

원래는 안되는데 blochain 부분이 리팩토링 전이라 일단 보류

@Yeonu-Kim Yeonu-Kim linked an issue Jun 22, 2026 that may be closed by this pull request
@Yeonu-Kim Yeonu-Kim merged commit 242ddd7 into main Jun 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auth 패키지 아키텍처 변경

1 participant