diff --git a/backend/main.py b/backend/main.py index ecda986..c10c6c6 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1082,57 +1082,333 @@ def api_update_email( @app.get( "/verify-email", response_class=HTMLResponse, + summary="Verify email address", ) -def api_verify_email(token: str = Query(...)): +def api_verify_email( + token: str = Query(...), +): result = verify_email(token) if result["status"] == "failed": if result["reason"] == "token_expired": - return """ - - - - - Verification expired - - -

Verification expired

-

This verification link has expired.

- - - """ + return HTMLResponse( + content=""" + + + + + - return """ - - - - - Verification failed - - -

Verification failed

-

This verification link is invalid.

- - - """ + Verification expired - return """ - - - - - - Email verified - - -
-

Email verified

-

Your email address has been successfully verified.

-

You may now close this tab.

+ + + + +
+
!
+ +

Verification expired

+ +

+ This email verification link has expired. + Please request a new verification email. +

+ + - - - """ +
+ + + """, + status_code=410, + ) + + return HTMLResponse( + content=""" + + + + + + + Verification failed + + + + + +
+
×
+ +

Verification failed

+ +

+ This verification link is invalid or has already been used. +

+ + +
+ + + """, + status_code=400, + ) + + return HTMLResponse( + content=""" + + + + + + + Email verified + + + + + +
+
+ +

Email verified

+ +

+ Your email address has been successfully verified. +

+ +

+ You may now close this tab. +

+ + +
+ + + """, + ) @app.post( "/forgot-password", @@ -1147,47 +1423,194 @@ def api_forgot_password( @app.get( "/update-password_page", response_class=HTMLResponse, + summary="Password reset page", ) -def update_password_page(token: str = Query(...)): - return f""" - - - - - - Reset password - - +def update_password_page( + token: str = Query(...), +): + return HTMLResponse( + content=f""" + + + + + + + Reset password + + + + + +
+

Reset password

-
+

+ Enter a new password for your account. +

+ + -
+ + + """, + ) @app.post( "/update-password", response_class=HTMLResponse, + summary="Reset password", ) def update_password( token: str = Form(...), @@ -1199,49 +1622,219 @@ def update_password( ) if result["status"] == "failed": + if result["reason"] == "token_expired": - return """ - - - - - Reset expired - - -

Reset link expired

-

This password reset link has expired.

- - - """ + return HTMLResponse( + content=""" + + + + + - return """ - - - - - Reset failed - - -

Reset failed

-

This password reset link is invalid.

- - - """ + Reset link expired + + + + + +
+

Reset link expired

+ +

+ This password reset link has expired. + Please request a new password reset. +

+
+ + + """, + status_code=410, + ) + + return HTMLResponse( + content=""" + + + + + + + Reset failed + + + + + +
+

Reset failed

+ +

+ This password reset link is invalid or has already been used. +

+
+ + + """, + status_code=400, + ) + + return HTMLResponse( + content=""" + + + + + + + Password updated + + + + + +
+
- return """ - - - - - Password updated - -

Password updated

-

Your password has been successfully changed.

-

You may now close this tab.

- - - """ + +

+ Your password has been successfully changed. +

+ +

+ You may now close this tab. +

+
+ + + """, + ) # easter egg