File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -97,3 +97,20 @@ def reset_password():
9797 u .save ()
9898 current_app .logger .debug ("/auth/password/reset -> Password reset successfully" )
9999 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" )
Original file line number Diff line number Diff line change @@ -959,6 +959,43 @@ paths:
959959 message :
960960 type : string
961961 example : Password reset successful.
962+ /auth/password/check_token :
963+ post :
964+ summary : Check the token validity
965+ operationId : checkToken
966+ tags :
967+ - Authentication
968+ requestBody :
969+ description : Parameters to test the token
970+ required : true
971+ content :
972+ application/json :
973+ schema :
974+ type : object
975+ properties :
976+ token :
977+ type : string
978+ required : true
979+ example : qwERg3rtyhog23mrweof5ngib4j3ktnrvwefqjskldnakms
980+ responses :
981+ " 400 " :
982+ $ref : ' #/components/responses/BadRequest'
983+ " 200 " :
984+ description : Success
985+ content :
986+ application/json :
987+ schema :
988+ type : object
989+ properties :
990+ code :
991+ type : string
992+ example : 200
993+ success :
994+ type : boolean
995+ example : true
996+ message :
997+ type : string
998+ example : Reset token is correct.
962999
9631000
9641001servers :
You can’t perform that action at this time.
0 commit comments