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)
@app.post(
@app.get(
"/update-password",
summary="Reset password with token",
description="Sets a new password using a password reset token.",
)
def api_update_password(
data: PasswordReset,
):
result = reset_password_with_token(
data.token,
data.new_password,
response_class=HTMLResponse,
)
def update_password_page(token: str = Query(...)):
return f"""
<!DOCTYPE html>
<html lang="en">
<head>
<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":
raise HTTPException(
status_code=400,
detail=result["reason"],
)
<form method="post" action="/api/update-password">
<input
type="hidden"
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