from functools import wraps
from flask import g, request, redirect, url_for

def login_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        auth = request.authorization

        if auth == None:
            return redirect(url_for('/api.rest_user_forbidden', next=request.url))
        return f(*args, **kwargs)

    return decorated_function

