{"action":"created","issue":{"url":"https://api.github.com/repos/OptimalBits/node_acl/issues/170","repository_url":"https://api.github.com/repos/OptimalBits/node_acl","labels_url":"https://api.github.com/repos/OptimalBits/node_acl/issues/170/labels{/name}","comments_url":"https://api.github.com/repos/OptimalBits/node_acl/issues/170/comments","events_url":"https://api.github.com/repos/OptimalBits/node_acl/issues/170/events","html_url":"https://github.com/OptimalBits/node_acl/issues/170","id":134335618,"number":170,"title":"acl.middleware causes Error: Broke parameter contract","user":{"login":"vrghost242","id":12150067,"avatar_url":"https://avatars.githubusercontent.com/u/12150067?v=3","gravatar_id":"","url":"https://api.github.com/users/vrghost242","html_url":"https://github.com/vrghost242","followers_url":"https://api.github.com/users/vrghost242/followers","following_url":"https://api.github.com/users/vrghost242/following{/other_user}","gists_url":"https://api.github.com/users/vrghost242/gists{/gist_id}","starred_url":"https://api.github.com/users/vrghost242/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrghost242/subscriptions","organizations_url":"https://api.github.com/users/vrghost242/orgs","repos_url":"https://api.github.com/users/vrghost242/repos","events_url":"https://api.github.com/users/vrghost242/events{/privacy}","received_events_url":"https://api.github.com/users/vrghost242/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-02-17T16:50:30Z","updated_at":"2016-06-09T16:47:18Z","closed_at":null,"body":"So thought I would set up acl for my site, and it seemed like using the mongoose _id was an easy way to use the system. Thought I would use acl.middleware to define check if the user have the right to call a specific route.\r\n\r\nI load acl as follows\r\n```var acl = require('acl');\r\n//Lets start the acl as well\r\nacl = new acl(new acl.mongodbBackend(cfgDB.mongoUrl, 'acl'));```\r\n\r\nI then created a function to return the value of req.user._id\r\n```\r\nfunction getUserId(req, res){\r\n    userId=req.user._id;\r\n    return(userId)\r\n}\r\n```\r\nThe document for acl.middleware does indicate that it should be able to use such a function, but I am not certain if that is the right way to do it :)\r\n\r\nLast the route it self\r\n\r\n```\r\n//router.post()\r\nrouter.get('/rest/access/list/me', acl.middleware(3,getUserId,\"read\"), function(req, res, next){\r\n\r\n    var reply = {};\r\n    reply.whoami = req.user._id;\r\n    reply.url = req.url;\r\n    res.send(reply)\r\n})\r\n```\r\n\r\nI am not certain how I would call getUserId ensuring that req,res, or if acl.middleware should even be used that way, but I get the following error message. \r\n\r\n<h1>Broke parameter contract</h1>\r\n<h2></h2>\r\n<pre>Error: Broke parameter contract\r\n    at Function.contract.end (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/acl/lib/contract.js:51:11)\r\n    at Acl.isAllowed (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/acl/lib/acl.js:464:6)\r\n    at /Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/acl/lib/acl.js:639:9\r\n    at Layer.handle [as handle_request] (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/layer.js:95:5)\r\n    at next (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/route.js:131:13)\r\n    at Route.dispatch (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/route.js:112:3)\r\n    at Layer.handle [as handle_request] (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/layer.js:95:5)\r\n    at /Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/index.js:277:22\r\n    at Function.process_params (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/index.js:330:12)\r\n    at next (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/index.js:271:10)\r\n    at Function.handle (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/index.js:176:3)\r\n    at router (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/index.js:46:12)\r\n    at Layer.handle [as handle_request] (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/layer.js:95:5)\r\n    at trim_prefix (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/index.js:312:13)\r\n    at /Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/index.js:280:7\r\n    at Function.process_params (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/index.js:330:12)\r\n    at next (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/lib/router/index.js:271:10)\r\n    at SendStream.error (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/node_modules/serve-static/index.js:120:7)\r\n    at emitOne (events.js:77:13)\r\n    at SendStream.emit (events.js:169:7)\r\n    at SendStream.error (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/node_modules/send/index.js:245:17)\r\n    at SendStream.onStatError (/Users/bengtbjorkberg/WebstormProjects/DBFSKnowledge2/node_modules/express/node_modules/send/index.js:356:12)</pre>\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/OptimalBits/node_acl/issues/comments/224955834","html_url":"https://github.com/OptimalBits/node_acl/issues/170#issuecomment-224955834","issue_url":"https://api.github.com/repos/OptimalBits/node_acl/issues/170","id":224955834,"user":{"login":"ajmueller","id":1442179,"avatar_url":"https://avatars.githubusercontent.com/u/1442179?v=3","gravatar_id":"","url":"https://api.github.com/users/ajmueller","html_url":"https://github.com/ajmueller","followers_url":"https://api.github.com/users/ajmueller/followers","following_url":"https://api.github.com/users/ajmueller/following{/other_user}","gists_url":"https://api.github.com/users/ajmueller/gists{/gist_id}","starred_url":"https://api.github.com/users/ajmueller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajmueller/subscriptions","organizations_url":"https://api.github.com/users/ajmueller/orgs","repos_url":"https://api.github.com/users/ajmueller/repos","events_url":"https://api.github.com/users/ajmueller/events{/privacy}","received_events_url":"https://api.github.com/users/ajmueller/received_events","type":"User","site_admin":false},"created_at":"2016-06-09T16:47:17Z","updated_at":"2016-06-09T16:47:17Z","body":"@vrghost242 no worries, I got it working!  It was a really dumb mistake on my part.  In my app file, while bootstrapping the application, I required the route files before I actually connected to my database, so they didn't know what the database connection value was."}}
{"actor":{"display_login":"ajmueller"}}