Update main.py
Browse files
main.py
CHANGED
@@ -45,9 +45,12 @@ async def login_post(
|
|
45 |
request: Request,
|
46 |
email: str = Form(...),
|
47 |
password: str = Form(...),
|
48 |
-
db: Session = Depends(get_db)
|
|
|
49 |
):
|
50 |
-
|
|
|
|
|
51 |
|
52 |
# Validate the email and password
|
53 |
if not email or not password:
|
|
|
45 |
request: Request,
|
46 |
email: str = Form(...),
|
47 |
password: str = Form(...),
|
48 |
+
db: Session = Depends(get_db),
|
49 |
+
token: str = Depends(verify_token), # Check if the user has a valid token
|
50 |
):
|
51 |
+
if token:
|
52 |
+
# If the user already has a valid token, redirect to protected.html
|
53 |
+
return templates.TemplateResponse("protected.html", {"request": request, "user": token})
|
54 |
|
55 |
# Validate the email and password
|
56 |
if not email or not password:
|