for something like this
@post("/email-verification/request", status_code=status_codes.HTTP_204_NO_CONTENT)
async def request_email_verification(
self,
data: RequestEmailVerificationRequest,
account_service: AccountService,
smtp_client: SMTPClient,
captcha_client: CaptchaClient,
) -> None:
"""Request email verification for an account."""
await account_service.request_email_verification(
email=data.email,
smtp_client=smtp_client,
captcha_client=captcha_client,
captcha_token=data.captcha,
)
async def request_email_verification(
self,
email: str,
smtp_client: SMTPClient,
captcha_client: captcha.CaptchaClient,
captcha_token: str | UnsetType,
) -> None:
await self._verify_captcha(captcha_client, captcha_token)
account = await self.get_one_or_none(email=email)
if account is None:
return
vs = account.email_verification_status
if vs is EmailVerificationStatus.PENDING:
await self.initiate_email_verification(account, smtp_client)
elif vs is EmailVerificationStatus.VERIFIED:
await self.initiate_password_reset(account, smtp_client)
i would have to tell the controller which event to emit too right since this can trigger two things, wont this get ugly?