Finished test for user-router

This commit is contained in:
Mawoka
2022-04-16 17:56:44 +02:00
parent 78df99d837
commit a561537f05
5 changed files with 48 additions and 6 deletions
+2 -2
View File
@@ -205,11 +205,11 @@ class ForgotPassword(BaseModel):
@router.post("/forgot-password")
async def forgotten_password(forgot_password: ForgotPassword):
async def forgotten_password(forgot_password: ForgotPassword, background_task: BackgroundTasks):
user = await User.objects.filter(email=forgot_password.email, verified=True).get_or_none()
if user is None:
raise HTTPException(status_code=404, detail="User not found")
await send_forgotten_password_email(user.email)
background_task.add_task(send_forgotten_password_email, email=user.email)
return {"message": "Password reset email sent"}