Ejemplo n.º 1
0
async def update_owner(
    *,
    db: Session = Depends(get_db),
    data: OwnerUpdate,
    current_owner: DBOwnerModel = Depends(get_current_owner),
    background_tasks: BackgroundTasks,
):
    """If new `email` is found in data, email will no longer be
    verified and new OTP as well as OTP datetime will be generated.
    """
    otp = None
    if data.email and data.email != current_owner.email:
        otp = generate_random_otp()
    with expected_integrity_error(
        db, detail="There was a conflict with an existing owner", debug=False
    ):
        if owner := update_owner_info(db, data=data, owner=current_owner, otp=otp):
            if otp and owner.email:
                background_tasks.add_task(send_email_verify_otp, owner.email, otp)
Ejemplo n.º 2
0
 def __init__(self) -> None:
     self.id = None
     self.email = self.random_email()
     self.password = self.random_lower_string()
     self.otp = generate_random_otp()