{"action":"created","issue":{"url":"https://api.github.com/repos/Urigo/angular-meteor/issues/301","labels_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/301/labels{/name}","comments_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/301/comments","events_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/301/events","html_url":"https://github.com/Urigo/angular-meteor/pull/301","id":68940537,"number":301,"title":"Allow to use a checker function before resolving","user":{"login":"auterium","id":4732632,"avatar_url":"https://avatars.githubusercontent.com/u/4732632?v=3","gravatar_id":"","url":"https://api.github.com/users/auterium","html_url":"https://github.com/auterium","followers_url":"https://api.github.com/users/auterium/followers","following_url":"https://api.github.com/users/auterium/following{/other_user}","gists_url":"https://api.github.com/users/auterium/gists{/gist_id}","starred_url":"https://api.github.com/users/auterium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auterium/subscriptions","organizations_url":"https://api.github.com/users/auterium/orgs","repos_url":"https://api.github.com/users/auterium/repos","events_url":"https://api.github.com/users/auterium/events{/privacy}","received_events_url":"https://api.github.com/users/auterium/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/Urigo/angular-meteor/milestones/3","html_url":"https://github.com/Urigo/angular-meteor/milestones/0.8.5","labels_url":"https://api.github.com/repos/Urigo/angular-meteor/milestones/3/labels","id":1073946,"number":3,"title":"0.8.5","description":"","creator":{"login":"Urigo","id":1297448,"avatar_url":"https://avatars.githubusercontent.com/u/1297448?v=3","gravatar_id":"","url":"https://api.github.com/users/Urigo","html_url":"https://github.com/Urigo","followers_url":"https://api.github.com/users/Urigo/followers","following_url":"https://api.github.com/users/Urigo/following{/other_user}","gists_url":"https://api.github.com/users/Urigo/gists{/gist_id}","starred_url":"https://api.github.com/users/Urigo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Urigo/subscriptions","organizations_url":"https://api.github.com/users/Urigo/orgs","repos_url":"https://api.github.com/users/Urigo/repos","events_url":"https://api.github.com/users/Urigo/events{/privacy}","received_events_url":"https://api.github.com/users/Urigo/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":2,"state":"open","created_at":"2015-04-19T13:06:43Z","updated_at":"2015-04-22T19:17:05Z","due_on":"2015-04-28T21:00:00Z","closed_at":null},"comments":14,"created_at":"2015-04-16T14:49:33Z","updated_at":"2015-04-23T20:37:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Urigo/angular-meteor/pulls/301","html_url":"https://github.com/Urigo/angular-meteor/pull/301","diff_url":"https://github.com/Urigo/angular-meteor/pull/301.diff","patch_url":"https://github.com/Urigo/angular-meteor/pull/301.patch"},"body":"Current behaviour: when using $meteor.requireUser(), a resolved promise will be returned if there is an authenticated user, and a rejection if not.\r\n\r\nProposed behaviour: allow $meteor.requireUser() to receive a function that will evaluate if the logged user has permission or not.\r\n\r\nUsage:\r\nThe received function will be executed with the user object as the only paramenter. If the function returns a string, such string will be used to reject the resolution; otherwise it will resolve with the user as expected.\r\n\r\nExample:\r\n```javascript\r\n$stateProvider.state('secure-page', {\r\n  url: '/my-top-secret-page',\r\n  templateUrl: 'my/top/secret/page.ng.html',\r\n  resolve: {\r\n    currentUser: ['$meteor', function($meteor) {\r\n      return $meteor.requireUser(function(user) {\r\n        if(!_.contains(user.roles, 'root')) {\r\n          return 'FORBIDDEN';\r\n        }\r\n      });\r\n    }]\r\n  }\r\n});\r\n```\r\n\r\nUse cases:\r\n- Role based access control\r\n- Check for active/suspended account\r\n\r\nRegards,\r\nMarc"},"comment":{"url":"https://api.github.com/repos/Urigo/angular-meteor/issues/comments/95712612","html_url":"https://github.com/Urigo/angular-meteor/pull/301#issuecomment-95712612","issue_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/301","id":95712612,"user":{"login":"Urigo","id":1297448,"avatar_url":"https://avatars.githubusercontent.com/u/1297448?v=3","gravatar_id":"","url":"https://api.github.com/users/Urigo","html_url":"https://github.com/Urigo","followers_url":"https://api.github.com/users/Urigo/followers","following_url":"https://api.github.com/users/Urigo/following{/other_user}","gists_url":"https://api.github.com/users/Urigo/gists{/gist_id}","starred_url":"https://api.github.com/users/Urigo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Urigo/subscriptions","organizations_url":"https://api.github.com/users/Urigo/orgs","repos_url":"https://api.github.com/users/Urigo/repos","events_url":"https://api.github.com/users/Urigo/events{/privacy}","received_events_url":"https://api.github.com/users/Urigo/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T20:37:00Z","updated_at":"2015-04-23T20:37:00Z","body":"Guys, this is a great discussion!\r\n\r\n@auterium I think your last suggestion answers everyones needs.  can you please change the pull request to that and I will merge it?"}}