update
This commit is contained in:
+36
-16
@@ -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(
|
|
||||||
data: PasswordReset,
|
|
||||||
):
|
|
||||||
result = reset_password_with_token(
|
|
||||||
data.token,
|
|
||||||
data.new_password,
|
|
||||||
)
|
)
|
||||||
|
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":
|
<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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user