File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,25 @@ def check_if_token_is_revoked(decrypted_token):
257257 application .register_blueprint (debug_bp )
258258
259259
260+ @jwt .revoked_token_loader
261+ def jwt_revoked_token_callback ():
262+ return (
263+ jsonify (
264+ {
265+ "code" : 401 ,
266+ "error" : {
267+ "message" : "Token has been revoked." ,
268+ "name" : "Unauthorized Error" ,
269+ "solution" : "Please login again" ,
270+ "type" : "UnauthorizedError" ,
271+ },
272+ "success" : False ,
273+ }
274+ ),
275+ 401 ,
276+ )
277+
278+
260279@jwt .unauthorized_loader
261280def no_jwt_callback (error_message ):
262281 return (
@@ -276,6 +295,25 @@ def no_jwt_callback(error_message):
276295 )
277296
278297
298+ @jwt .invalid_token_loader
299+ def jwt_invalid_token_callback (error_message ):
300+ return (
301+ jsonify (
302+ {
303+ "code" : 400 ,
304+ "error" : {
305+ "message" : error_message ,
306+ "name" : "Bad Request Error" ,
307+ "solution" : "Try again (The token is invalid)" ,
308+ "type" : "BadRequestError" ,
309+ },
310+ "success" : False ,
311+ }
312+ ),
313+ 400 ,
314+ )
315+
316+
279317# import tasks here to be registered by celery
280318
281319import PyMatcha .utils .tasks # noqa
You can’t perform that action at this time.
0 commit comments