This commit is contained in:
ben
2026-08-18 17:31:17 +02:00
parent 662baca9e6
commit 34416ad804
+36 -16
View File
@@ -1139,26 +1139,46 @@ def api_forgot_password(
): ):
return reset_password(data.email) return reset_password(data.email)
@app.post( @app.get(
"/update-password", "/update-password",
summary="Reset password with token", response_class=HTMLResponse,
description="Sets a new password using a password reset token.",
) )
def api_update_password( def update_password_page(token: str = Query(...)):
data: PasswordReset, return f"""
): <!DOCTYPE html>
result = reset_password_with_token( <html lang="en">
data.token, <head>
data.new_password, <meta charset="UTF-8">
) <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reset password</title>
</head>
<body>
<h1>Reset password</h1>
if result["status"] == "failed": <form method="post" action="/api/update-password">
raise HTTPException( <input
status_code=400, type="hidden"
detail=result["reason"], name="token"
) value="{token}"
>
return result <label>
New password:
<input
type="password"
name="new_password"
minlength="8"
required
>
</label>
<button type="submit">
Reset password
</button>
</form>
</body>
</html>
"""
# easter egg # easter egg