from app import db


def open_cursor_hook(req, res, resource, params):
    resource.db = db
    resource.cursor = db.cursor()


def close_cursor_hook(req, res, resource):
    resource.cursor.close()

@@ -1,8 +1,22 @@
+import falcon%0A
 from app
@@ -206,8 +206,171 @@
 close()%0A
+%0A%0Adef auth_required(req, res, resource):%0A    if req.context%5B'auth_user'%5D is None:%0A        raise falcon.HTTPUnauthorized('Unauthorized', %22Authentication required%22)%0A

Add auth required hook