Gregniuki commited on
Commit
2824b0b
·
1 Parent(s): 316bb4c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +2 -2
main.py CHANGED
@@ -118,7 +118,7 @@ async def verify_email(verification_token: str, request: Request, db: Session =
118
  return RedirectResponse("/protected")
119
 
120
  # User authentication (protected route)
121
- @app.get("/protected", response_model=str)
122
  async def protected_route(request: Request, token: str = Depends(oauth2_scheme), db: Session = Depends(get_db)):
123
  # Verify the access token
124
  user = verify_token(token, my_secret_key, "HS256")
@@ -132,4 +132,4 @@ async def protected_route(request: Request, token: str = Depends(oauth2_scheme),
132
  raise HTTPException(status_code=401, detail="User not found in the database")
133
 
134
  # The user exists in the database, and you can render the protected route template
135
- return templates.TemplateResponse("protected.html", {"request": request, "user": db_user.username})
 
118
  return RedirectResponse("/protected")
119
 
120
  # User authentication (protected route)
121
+ @app.get("/protected", response_class=HTMLResponse) # Specify response_class as HTMLResponse
122
  async def protected_route(request: Request, token: str = Depends(oauth2_scheme), db: Session = Depends(get_db)):
123
  # Verify the access token
124
  user = verify_token(token, my_secret_key, "HS256")
 
132
  raise HTTPException(status_code=401, detail="User not found in the database")
133
 
134
  # The user exists in the database, and you can render the protected route template
135
+ return templates.TemplateResponse("protected.html", {"request": request, "user": db_user.username})