update
This commit is contained in:
+36
-16
@@ -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.",
|
||||
response_class=HTMLResponse,
|
||||
)
|
||||
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":
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user