<gh_stars>0

import jwt

from functools import wraps
from flask import request, jsonify

from main import (
    app
)

def authorization(func):
    @wraps(func)
    def wrap():
        try:
            token = request.json['token']
            payload = jwt.decode(token,
                app.config['SECRET KEY'],
                algorithms=['HS256'])

        except jwt.ExpiredSignatureError:
            return  jsonify({'message':'expired token'}), 401

        except jwt.InvalidTokenError:   
            return jsonify({'message':'Invalid token'}), 401
            
        except jwt.InvalidKeyError:
            return jsonify({'message':'Invalid key'}), 401

        return func  
    return wrap



import jwt

from functools import wraps
from flask import request, jsonify

from main import (
    app
)

def authorization(func):
    @wraps(func)
    def wrap():
        try:
            token = request.json['token']
            payload = jwt.decode(token,
                app.config['SECRET KEY'],
                algorithms=['HS256'])

        except jwt.ExpiredSignatureError:
            return  jsonify({'message':'expired token'}), 401

        except jwt.InvalidTokenError:   
            return jsonify({'message':'Invalid token'}), 401
            
        except jwt.InvalidKeyError:
            return jsonify({'message':'Invalid key'}), 401

        return func  
    return wrap