@@ -0,0 +1,922 @@
+from functools import wraps%0A%0Afrom flask import jsonify, request, make_response%0A%0Afrom app.models import User%0A%0A%0Adef evaluate_auth(function):%0A    @wraps(function)%0A    def decorator(*args, **kwargs):%0A        header = request.headers.get(%22Authorization%22)%0A        if header:%0A            token = header%0A            # extract user_id from token%0A            user_id = User.verify_token(token)%0A            if not isinstance(user_id, str):%0A                return function(user_id=user_id, *args, **kwargs)%0A            else:%0A                response = jsonify(%7B%0A                    %22message%22: user_id%0A                %7D)%0A                response.status_code = 401%0A                return response%0A%0A        else:%0A            # if token is missing%0A            response = %7B%0A                %22message%22: %22Register or log in to access this resource%22%0A            %7D%0A            return make_response(jsonify(response)), 401%0A%0A    return decorator%0A

Edit attribute errors