Update OTP value and valid time before resend
This commit is contained in:
@@ -3,7 +3,7 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.external_services import resend_otp, send_otp
|
||||
from app.schemas import *
|
||||
from database.crud import add_user, get_db, verify_otp
|
||||
from database.crud import *
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -29,7 +29,8 @@ def validate_otp(data: OTPVerify, db: Session = Depends(get_db)):
|
||||
return response
|
||||
|
||||
|
||||
@router.post("/resendOTP", response_model=OTPresendResponse)
|
||||
def deliver_otp(data: OTPresend, db: Session = Depends(get_db)):
|
||||
@router.post("/resendOTP", response_model=OTPResendResponse)
|
||||
def deliver_otp(data: OTPResend, db: Session = Depends(get_db)):
|
||||
update_otp(data=data, db=db)
|
||||
response = resend_otp(data=data, db=db)
|
||||
return response
|
||||
|
||||
@@ -106,14 +106,16 @@ class OTPVerifyResponse(OTPBase):
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class OTPresend(BaseModel):
|
||||
class OTPResend(BaseModel):
|
||||
email: EmailStr
|
||||
otp: int = randbits(20)
|
||||
otp_valid_time: datetime = datetime.now() + timedelta(minutes=10)
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class OTPresendResponse(UserCreateResponse):
|
||||
class OTPResendResponse(UserCreateResponse):
|
||||
pass
|
||||
|
||||
class Config:
|
||||
|
||||
Reference in New Issue
Block a user