update
This commit is contained in:
+59
-1
@@ -1140,7 +1140,7 @@ def api_forgot_password(
|
|||||||
return reset_password(data.email)
|
return reset_password(data.email)
|
||||||
|
|
||||||
@app.get(
|
@app.get(
|
||||||
"/update-password",
|
"/update-password_page",
|
||||||
response_class=HTMLResponse,
|
response_class=HTMLResponse,
|
||||||
)
|
)
|
||||||
def update_password_page(token: str = Query(...)):
|
def update_password_page(token: str = Query(...)):
|
||||||
@@ -1180,6 +1180,64 @@ def update_password_page(token: str = Query(...)):
|
|||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@app.post(
|
||||||
|
"/update-password",
|
||||||
|
response_class=HTMLResponse,
|
||||||
|
)
|
||||||
|
def update_password(
|
||||||
|
token: str = Form(...),
|
||||||
|
new_password: str = Form(...),
|
||||||
|
):
|
||||||
|
result = reset_password_with_token(
|
||||||
|
token,
|
||||||
|
new_password,
|
||||||
|
)
|
||||||
|
|
||||||
|
if result["status"] == "failed":
|
||||||
|
if result["reason"] == "token_expired":
|
||||||
|
return """
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Reset expired</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Reset link expired</h1>
|
||||||
|
<p>This password reset link has expired.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
return """
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Reset failed</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Reset failed</h1>
|
||||||
|
<p>This password reset link is invalid.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
return """
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Password updated</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Password updated</h1>
|
||||||
|
<p>Your password has been successfully changed.</p>
|
||||||
|
<p>You may now close this tab.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
# easter egg
|
# easter egg
|
||||||
|
|
||||||
@app.get(
|
@app.get(
|
||||||
|
|||||||
Reference in New Issue
Block a user