Update main.py
Browse files
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",
|
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})
|