def token_required(f):

    @wraps(f)
    def decorated(*args, **kwargs):
        token = request.headers['token']
        if (not token):
            return (jsonify({'error': 'Token no existe'}), 403)
        try:
            data = jwt.decode(token, app.config['SECRET_KEY'])
            current_user = Usuario.query.filter_by(nick=data['nick']).first()
            current_user = data['nick']
        except:
            return (jsonify({'error': 'Token no valido'}), 403)
        return f(current_user, *args, **kwargs)
    return decorated
def token_required(f):

    @wraps(f)
    def decorated(*args, **kwargs):
        token = request.headers['token']
        if (not token):
            return (jsonify({'error': 'Token no existe'}), 403)
        try:
            data = jwt.decode(token, app.config['SECRET_KEY'])
            current_user = Usuario.query.filter_by(nick=data['nick']).first()
            current_user = data['nick']
        except:
            return (jsonify({'error': 'Token no valido'}), 403)
        return f(current_user, *args, **kwargs)
    return decorated