Implement password reset

This commit is contained in:
2020-10-08 21:23:19 +02:00
parent 0b53bbaa70
commit 6c4d6919d7
4 changed files with 55 additions and 5 deletions

View File

@@ -37,7 +37,12 @@ def deliver_otp(data: OTPResend, db: Session = Depends(get_db)):
@router.post("/forgot_password", response_model=ForgotPasswordResponse)
def forgot_password(data: ForgotPassword, db: Session = Depends(get_db)):
mark_password_reset(data=data, db=db)
update_otp(data=data, db=db)
response = resend_otp(data=data, db=db)
return response
@router.post("/reset_password", response_model=ResetPasswordResponse)
def reset_password(data: ResetPassword, db: Session = Depends(get_db)):
response = verify_password_reset(data=data, db=db)
return response

View File

@@ -122,8 +122,15 @@ class OTPResendResponse(UserCreateResponse):
orm_mode = True
class ForgotPassword(BaseModel):
email: EmailStr
class ForgotPassword(OTPResend):
pass
class Config:
orm_mode = True
class ResetPassword(ForgotPassword):
password: str
class Config:
orm_mode = True
@@ -138,8 +145,23 @@ class ForgotPasswordResponse(BaseModel):
orm_mode = True
access_key: str
otp: int = Query(None, ge=6, le=6)
class ResetPasswordResponse(BaseModel):
message: str = "The password has been updated"
class Config:
orm_mode = True
class MatchesList(BaseModel):
access_key: str
city_id: int
latitude: str
longitude: str
type: Optional[int] = Query(0, ge=0, le=2)
class Config:
orm_mode = True
class MatchesResponse(BaseModel):
pass