@@ -55,7 +55,8 @@ def forgot_password():
5555 pass
5656 else :
5757 token = generate_confirmation_token (email = data ["email" ], token_type = "reset" )
58- link = os .getenv ("APP_URL" ) + "/auth/password/forgot/" + token
58+ # link = os.getenv("APP_URL") + "/auth/password/forgot/" + token
59+ link = f"{ os .getenv ('FRONT_URL' )} /accounts/password/reset?token={ token } "
5960 rendered_html = render_template ("password_reset.html" , link = link )
6061 current_app .logger .debug ("/auth/password/forgot -> Sending worker request to send email" )
6162 send_mail_html .delay (dest = data ["email" ], subject = "Reset your password on PyMatcha" , html = rendered_html )
@@ -96,3 +97,20 @@ def reset_password():
9697 u .save ()
9798 current_app .logger .debug ("/auth/password/reset -> Password reset successfully" )
9899 return Success ("Password reset successful." )
100+
101+
102+ @auth_password_bp .route ("/auth/password/check_token" , methods = ["POST" ])
103+ @validate_params ({"token" : str })
104+ def check_token_validity ():
105+ data = request .get_json ()
106+ try :
107+ confirm_token (data ["token" ], expiration = 7200 )
108+ except (SignatureExpired , BadSignature ) as e :
109+ if e == SignatureExpired :
110+ current_app .logger .debug ("/auth/password/reset -> Signature Expired" )
111+ raise BadRequestError ("Signature Expired." , "Request another password reset and try again." )
112+ else :
113+ current_app .logger .debug ("/auth/password/reset -> Bad Signature" )
114+ raise BadRequestError ("Bad Signature." , "Request another password reset and try again." )
115+ else :
116+ return Success ("Reset token is correct" )
0 commit comments