{"action":"created","comment":{"url":"https://api.github.com/repos/smebberson/linz/pulls/comments/36054607","id":36054607,"diff_hunk":"@@ -15,6 +17,101 @@ function get (modelName, passByReference) {\n     return clone(linz.get('models')[modelName]);\n }\n \n+/**\n+ * Get permission data for a model\n+ * @param {Object}   req      Request data\n+ * @param {String}   modelName Model name\n+ * @param {Function} cb        Callback function\n+ * @return {Object}\n+ */\n+function getPermissions(req, modelName, cb) {\n+\n+    if (!linz.get('disable permission cache') && !req.linz.cache.permissions.models.invalidate && req.session.permissions && req.session.permissions[modelName]) {\n+        return cb(null, req.session.permissions[modelName]);\n+    }\n+","path":"lib/api/model.js","position":24,"original_position":24,"commit_id":"2ff6a9f97d26a86ef433ee2aec822e109891489c","original_commit_id":"2ff6a9f97d26a86ef433ee2aec822e109891489c","user":{"login":"sandytrinh","id":3323860,"avatar_url":"https://avatars.githubusercontent.com/u/3323860?v=3","gravatar_id":"","url":"https://api.github.com/users/sandytrinh","html_url":"https://github.com/sandytrinh","followers_url":"https://api.github.com/users/sandytrinh/followers","following_url":"https://api.github.com/users/sandytrinh/following{/other_user}","gists_url":"https://api.github.com/users/sandytrinh/gists{/gist_id}","starred_url":"https://api.github.com/users/sandytrinh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandytrinh/subscriptions","organizations_url":"https://api.github.com/users/sandytrinh/orgs","repos_url":"https://api.github.com/users/sandytrinh/repos","events_url":"https://api.github.com/users/sandytrinh/events{/privacy}","received_events_url":"https://api.github.com/users/sandytrinh/received_events","type":"User","site_admin":false},"body":"Done!","created_at":"2015-08-03T03:56:18Z","updated_at":"2015-08-03T03:56:18Z","html_url":"https://github.com/smebberson/linz/pull/89#discussion_r36054607","pull_request_url":"https://api.github.com/repos/smebberson/linz/pulls/89","_links":{"self":{"href":"https://api.github.com/repos/smebberson/linz/pulls/comments/36054607"},"html":{"href":"https://github.com/smebberson/linz/pull/89#discussion_r36054607"},"pull_request":{"href":"https://api.github.com/repos/smebberson/linz/pulls/89"}}},"pull_request":{"url":"https://api.github.com/repos/smebberson/linz/pulls/89","id":39571699,"html_url":"https://github.com/smebberson/linz/pull/89","diff_url":"https://github.com/smebberson/linz/pull/89.diff","patch_url":"https://github.com/smebberson/linz/pull/89.patch","issue_url":"https://api.github.com/repos/smebberson/linz/issues/89","number":89,"state":"open","locked":false,"title":"Implementation of a basic permission functionality","user":{"login":"smebberson","id":74628,"avatar_url":"https://avatars.githubusercontent.com/u/74628?v=3","gravatar_id":"","url":"https://api.github.com/users/smebberson","html_url":"https://github.com/smebberson","followers_url":"https://api.github.com/users/smebberson/followers","following_url":"https://api.github.com/users/smebberson/following{/other_user}","gists_url":"https://api.github.com/users/smebberson/gists{/gist_id}","starred_url":"https://api.github.com/users/smebberson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smebberson/subscriptions","organizations_url":"https://api.github.com/users/smebberson/orgs","repos_url":"https://api.github.com/users/smebberson/repos","events_url":"https://api.github.com/users/smebberson/events{/privacy}","received_events_url":"https://api.github.com/users/smebberson/received_events","type":"User","site_admin":false},"body":"This PR is the implementation of the functionality as discussed in #8.\r\n\r\n- [x] provide the ability to add to Linz's navigation structure (including a cache)\r\n- [x] create a no-op function that will provide access to everything as a default\r\n- [x] exclude permissions code from executing, if the no-op function has been overwritten\r\n- [x] implement the ability to control predefined permissions for **model routes**:\r\n    - [x] model create\r\n    - [x] model edit\r\n    - [x] model delete\r\n    - [x] model json\r\n    - [x] model export\r\n    - [x] model overview\r\n- [x] implement the ability to control **model route** permissions on custom model actions\r\n- [x] implement the ability to control predefined permissions for **model views**:\r\n    - [x] model create\r\n    - [x] model edit\r\n    - [x] model delete\r\n    - [x] model json\r\n    - [x] model export\r\n    - [x] model overview\r\n- [x] implement the ability to control **model view** permissions for custom model actions\r\n- [x] implement the ability to control predefined permissions for **config routes**:\r\n    - [x] config overview\r\n    - [x] config reset\r\n    - [x] config edit\r\n    - [x] config json\r\n- [x] implement the ability to control predefined permissions for **config views**:\r\n    - [x] config overview\r\n    - [x] config reset\r\n    - [x] config edit\r\n    - [x] config json\r\n- [x] cache data per user session for:\r\n - [x] navigation\r\n - [x] model permissions\r\n - [x] configs permissions\r\n- [x] provide a public middleware `linz.middleware.exclusions`","created_at":"2015-07-09T11:09:21Z","updated_at":"2015-08-03T03:56:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3d466153e823718d438018b9c09f34075355e9b4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/smebberson/linz/pulls/89/commits","review_comments_url":"https://api.github.com/repos/smebberson/linz/pulls/89/comments","review_comment_url":"https://api.github.com/repos/smebberson/linz/pulls/comments{/number}","comments_url":"https://api.github.com/repos/smebberson/linz/issues/89/comments","statuses_url":"https://api.github.com/repos/smebberson/linz/statuses/2ff6a9f97d26a86ef433ee2aec822e109891489c","head":{"label":"smebberson:permissions","ref":"permissions","sha":"2ff6a9f97d26a86ef433ee2aec822e109891489c","user":{"login":"smebberson","id":74628,"avatar_url":"https://avatars.githubusercontent.com/u/74628?v=3","gravatar_id":"","url":"https://api.github.com/users/smebberson","html_url":"https://github.com/smebberson","followers_url":"https://api.github.com/users/smebberson/followers","following_url":"https://api.github.com/users/smebberson/following{/other_user}","gists_url":"https://api.github.com/users/smebberson/gists{/gist_id}","starred_url":"https://api.github.com/users/smebberson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smebberson/subscriptions","organizations_url":"https://api.github.com/users/smebberson/orgs","repos_url":"https://api.github.com/users/smebberson/repos","events_url":"https://api.github.com/users/smebberson/events{/privacy}","received_events_url":"https://api.github.com/users/smebberson/received_events","type":"User","site_admin":false},"repo":{"id":12881781,"name":"linz","full_name":"smebberson/linz","owner":{"login":"smebberson","id":74628,"avatar_url":"https://avatars.githubusercontent.com/u/74628?v=3","gravatar_id":"","url":"https://api.github.com/users/smebberson","html_url":"https://github.com/smebberson","followers_url":"https://api.github.com/users/smebberson/followers","following_url":"https://api.github.com/users/smebberson/following{/other_user}","gists_url":"https://api.github.com/users/smebberson/gists{/gist_id}","starred_url":"https://api.github.com/users/smebberson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smebberson/subscriptions","organizations_url":"https://api.github.com/users/smebberson/orgs","repos_url":"https://api.github.com/users/smebberson/repos","events_url":"https://api.github.com/users/smebberson/events{/privacy}","received_events_url":"https://api.github.com/users/smebberson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smebberson/linz","description":"NodeJS Content Management System","fork":false,"url":"https://api.github.com/repos/smebberson/linz","forks_url":"https://api.github.com/repos/smebberson/linz/forks","keys_url":"https://api.github.com/repos/smebberson/linz/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smebberson/linz/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smebberson/linz/teams","hooks_url":"https://api.github.com/repos/smebberson/linz/hooks","issue_events_url":"https://api.github.com/repos/smebberson/linz/issues/events{/number}","events_url":"https://api.github.com/repos/smebberson/linz/events","assignees_url":"https://api.github.com/repos/smebberson/linz/assignees{/user}","branches_url":"https://api.github.com/repos/smebberson/linz/branches{/branch}","tags_url":"https://api.github.com/repos/smebberson/linz/tags","blobs_url":"https://api.github.com/repos/smebberson/linz/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smebberson/linz/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smebberson/linz/git/refs{/sha}","trees_url":"https://api.github.com/repos/smebberson/linz/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smebberson/linz/statuses/{sha}","languages_url":"https://api.github.com/repos/smebberson/linz/languages","stargazers_url":"https://api.github.com/repos/smebberson/linz/stargazers","contributors_url":"https://api.github.com/repos/smebberson/linz/contributors","subscribers_url":"https://api.github.com/repos/smebberson/linz/subscribers","subscription_url":"https://api.github.com/repos/smebberson/linz/subscription","commits_url":"https://api.github.com/repos/smebberson/linz/commits{/sha}","git_commits_url":"https://api.github.com/repos/smebberson/linz/git/commits{/sha}","comments_url":"https://api.github.com/repos/smebberson/linz/comments{/number}","issue_comment_url":"https://api.github.com/repos/smebberson/linz/issues/comments{/number}","contents_url":"https://api.github.com/repos/smebberson/linz/contents/{+path}","compare_url":"https://api.github.com/repos/smebberson/linz/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smebberson/linz/merges","archive_url":"https://api.github.com/repos/smebberson/linz/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smebberson/linz/downloads","issues_url":"https://api.github.com/repos/smebberson/linz/issues{/number}","pulls_url":"https://api.github.com/repos/smebberson/linz/pulls{/number}","milestones_url":"https://api.github.com/repos/smebberson/linz/milestones{/number}","notifications_url":"https://api.github.com/repos/smebberson/linz/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smebberson/linz/labels{/name}","releases_url":"https://api.github.com/repos/smebberson/linz/releases{/id}","created_at":"2013-09-16T23:56:05Z","updated_at":"2015-05-08T04:22:36Z","pushed_at":"2015-08-03T00:27:10Z","git_url":"git://github.com/smebberson/linz.git","ssh_url":"git@github.com:smebberson/linz.git","clone_url":"https://github.com/smebberson/linz.git","svn_url":"https://github.com/smebberson/linz","homepage":null,"size":3072,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":24,"forks":1,"open_issues":24,"watchers":2,"default_branch":"master"}},"base":{"label":"smebberson:master","ref":"master","sha":"fa18d3b887d10af173fb5c38280ae82937efb043","user":{"login":"smebberson","id":74628,"avatar_url":"https://avatars.githubusercontent.com/u/74628?v=3","gravatar_id":"","url":"https://api.github.com/users/smebberson","html_url":"https://github.com/smebberson","followers_url":"https://api.github.com/users/smebberson/followers","following_url":"https://api.github.com/users/smebberson/following{/other_user}","gists_url":"https://api.github.com/users/smebberson/gists{/gist_id}","starred_url":"https://api.github.com/users/smebberson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smebberson/subscriptions","organizations_url":"https://api.github.com/users/smebberson/orgs","repos_url":"https://api.github.com/users/smebberson/repos","events_url":"https://api.github.com/users/smebberson/events{/privacy}","received_events_url":"https://api.github.com/users/smebberson/received_events","type":"User","site_admin":false},"repo":{"id":12881781,"name":"linz","full_name":"smebberson/linz","owner":{"login":"smebberson","id":74628,"avatar_url":"https://avatars.githubusercontent.com/u/74628?v=3","gravatar_id":"","url":"https://api.github.com/users/smebberson","html_url":"https://github.com/smebberson","followers_url":"https://api.github.com/users/smebberson/followers","following_url":"https://api.github.com/users/smebberson/following{/other_user}","gists_url":"https://api.github.com/users/smebberson/gists{/gist_id}","starred_url":"https://api.github.com/users/smebberson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smebberson/subscriptions","organizations_url":"https://api.github.com/users/smebberson/orgs","repos_url":"https://api.github.com/users/smebberson/repos","events_url":"https://api.github.com/users/smebberson/events{/privacy}","received_events_url":"https://api.github.com/users/smebberson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smebberson/linz","description":"NodeJS Content Management System","fork":false,"url":"https://api.github.com/repos/smebberson/linz","forks_url":"https://api.github.com/repos/smebberson/linz/forks","keys_url":"https://api.github.com/repos/smebberson/linz/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smebberson/linz/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smebberson/linz/teams","hooks_url":"https://api.github.com/repos/smebberson/linz/hooks","issue_events_url":"https://api.github.com/repos/smebberson/linz/issues/events{/number}","events_url":"https://api.github.com/repos/smebberson/linz/events","assignees_url":"https://api.github.com/repos/smebberson/linz/assignees{/user}","branches_url":"https://api.github.com/repos/smebberson/linz/branches{/branch}","tags_url":"https://api.github.com/repos/smebberson/linz/tags","blobs_url":"https://api.github.com/repos/smebberson/linz/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smebberson/linz/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smebberson/linz/git/refs{/sha}","trees_url":"https://api.github.com/repos/smebberson/linz/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smebberson/linz/statuses/{sha}","languages_url":"https://api.github.com/repos/smebberson/linz/languages","stargazers_url":"https://api.github.com/repos/smebberson/linz/stargazers","contributors_url":"https://api.github.com/repos/smebberson/linz/contributors","subscribers_url":"https://api.github.com/repos/smebberson/linz/subscribers","subscription_url":"https://api.github.com/repos/smebberson/linz/subscription","commits_url":"https://api.github.com/repos/smebberson/linz/commits{/sha}","git_commits_url":"https://api.github.com/repos/smebberson/linz/git/commits{/sha}","comments_url":"https://api.github.com/repos/smebberson/linz/comments{/number}","issue_comment_url":"https://api.github.com/repos/smebberson/linz/issues/comments{/number}","contents_url":"https://api.github.com/repos/smebberson/linz/contents/{+path}","compare_url":"https://api.github.com/repos/smebberson/linz/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smebberson/linz/merges","archive_url":"https://api.github.com/repos/smebberson/linz/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smebberson/linz/downloads","issues_url":"https://api.github.com/repos/smebberson/linz/issues{/number}","pulls_url":"https://api.github.com/repos/smebberson/linz/pulls{/number}","milestones_url":"https://api.github.com/repos/smebberson/linz/milestones{/number}","notifications_url":"https://api.github.com/repos/smebberson/linz/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smebberson/linz/labels{/name}","releases_url":"https://api.github.com/repos/smebberson/linz/releases{/id}","created_at":"2013-09-16T23:56:05Z","updated_at":"2015-05-08T04:22:36Z","pushed_at":"2015-08-03T00:27:10Z","git_url":"git://github.com/smebberson/linz.git","ssh_url":"git@github.com:smebberson/linz.git","clone_url":"https://github.com/smebberson/linz.git","svn_url":"https://github.com/smebberson/linz","homepage":null,"size":3072,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":24,"forks":1,"open_issues":24,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/smebberson/linz/pulls/89"},"html":{"href":"https://github.com/smebberson/linz/pull/89"},"issue":{"href":"https://api.github.com/repos/smebberson/linz/issues/89"},"comments":{"href":"https://api.github.com/repos/smebberson/linz/issues/89/comments"},"review_comments":{"href":"https://api.github.com/repos/smebberson/linz/pulls/89/comments"},"review_comment":{"href":"https://api.github.com/repos/smebberson/linz/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/smebberson/linz/pulls/89/commits"},"statuses":{"href":"https://api.github.com/repos/smebberson/linz/statuses/2ff6a9f97d26a86ef433ee2aec822e109891489c"}}}}