Open utterances-bot opened 3 years ago
Hi, thanks for the tutorial :D i have a problem with redirect response in the login function:
bson.errors.InvalidId: 'dashboard' is not a valid ObjectId, it must be a 12-byte input or a 24-character hex string
and this is my route on app.py
@app.get("/dashboard", response_class=HTMLResponse, dependencies=[Depends(manager)], tags=["Templates"])
async def dashboard(request: Request):
return templates.TemplateResponse("dashboard.html", {"request": request})
i don't know hat happens, I already tried in many ways :c im using MongoDB for the users
The top part is part of the error, this comes out at the end:
AttributeError: _ObjectId__id
INFO: 127.0.0.1:63440 - "GET /dashboard HTTP/1.1" 500 Internal Server Error
sorry, I forgot the loader XD
@manager.user_loader
def load_user(username: str):
user = users_collection.find_one({"username": str(username)})
if user:
return user
Please rename the argument tokenUrl with token_url in your LoginManager
FastAPI Auth + Login Page | dayDreams ++
Using auth in Fastapi and connecting it to a Login Form
https://blog.athulcyriac.xyz/fastapi-auth/