diff --git a/backend/main.py b/backend/main.py index 699c5fe..710da20 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1140,7 +1140,7 @@ def api_forgot_password( return reset_password(data.email) @app.get( - "/update-password", + "/update-password_page", response_class=HTMLResponse, ) def update_password_page(token: str = Query(...)): @@ -1180,6 +1180,64 @@ def update_password_page(token: str = Query(...)): """ +@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 """ + + + + + Reset expired + + +

Reset link expired

+

This password reset link has expired.

+ + + """ + + return """ + + + + + Reset failed + + +

Reset failed

+

This password reset link is invalid.

+ + + """ + + return """ + + + + + Password updated + + +

Password updated

+

Your password has been successfully changed.

+

You may now close this tab.

+ + + """ + # easter egg @app.get(