{"action":"created","comment":{"url":"https://api.github.com/repos/meanjs/mean/pulls/comments/52088492","id":52088492,"diff_hunk":"@@ -4,22 +4,28 @@\n  * Module dependencies\n  */\n var adminPolicy = require('../policies/admin.server.policy'),\n-  admin = require('../controllers/admin.server.controller');\n+  admin = require('../controllers/admin.server.controller'),\n+  passport = require('passport'),\n+  express = require('express');\n \n module.exports = function (app) {\n-  // User route registration first. Ref: #713\n-  require('./users.server.routes.js')(app);\n+  var router = express.Router();\n \n-  // Users collection routes\n-  app.route('/api/users')\n+  //Set JWT Auth for all Admin Routes\n+  router.all('*', passport.authenticate('jwt', { session: false }));\n+\n+  router.route('/')\n     .get(adminPolicy.isAllowed, admin.list);\n \n   // Single user routes\n-  app.route('/api/users/:userId')\n+  router.route('/:userId')\n     .get(adminPolicy.isAllowed, admin.read)\n     .put(adminPolicy.isAllowed, admin.update)\n     .delete(adminPolicy.isAllowed, admin.delete);\n \n   // Finish by binding the user middleware\n-  app.param('userId', admin.userByID);\n+  router.param('userId', admin.userByID);\n+\n+  app.use('/api/admin/users', router);","path":"modules/users/server/routes/admin.server.routes.js","position":33,"original_position":33,"commit_id":"c3bdd39d1169537340d483be986e93e611ca5f6e","original_commit_id":"f7d571c60cda5b34bae87d4f85727a3541e1f8f5","user":{"login":"ilanbiala","id":3695164,"avatar_url":"https://avatars.githubusercontent.com/u/3695164?v=3","gravatar_id":"","url":"https://api.github.com/users/ilanbiala","html_url":"https://github.com/ilanbiala","followers_url":"https://api.github.com/users/ilanbiala/followers","following_url":"https://api.github.com/users/ilanbiala/following{/other_user}","gists_url":"https://api.github.com/users/ilanbiala/gists{/gist_id}","starred_url":"https://api.github.com/users/ilanbiala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilanbiala/subscriptions","organizations_url":"https://api.github.com/users/ilanbiala/orgs","repos_url":"https://api.github.com/users/ilanbiala/repos","events_url":"https://api.github.com/users/ilanbiala/events{/privacy}","received_events_url":"https://api.github.com/users/ilanbiala/received_events","type":"User","site_admin":false},"body":"Why do you need a regex, why does a plain param not work?","created_at":"2016-02-05T23:46:33Z","updated_at":"2016-02-05T23:46:33Z","html_url":"https://github.com/meanjs/mean/pull/1163#discussion_r52088492","pull_request_url":"https://api.github.com/repos/meanjs/mean/pulls/1163","_links":{"self":{"href":"https://api.github.com/repos/meanjs/mean/pulls/comments/52088492"},"html":{"href":"https://github.com/meanjs/mean/pull/1163#discussion_r52088492"},"pull_request":{"href":"https://api.github.com/repos/meanjs/mean/pulls/1163"}}},"pull_request":{"url":"https://api.github.com/repos/meanjs/mean/pulls/1163","id":57283956,"html_url":"https://github.com/meanjs/mean/pull/1163","diff_url":"https://github.com/meanjs/mean/pull/1163.diff","patch_url":"https://github.com/meanjs/mean/pull/1163.patch","issue_url":"https://api.github.com/repos/meanjs/mean/issues/1163","number":1163,"state":"open","locked":false,"title":"feat(core): JWT Authentication","user":{"login":"trainerbill","id":3578259,"avatar_url":"https://avatars.githubusercontent.com/u/3578259?v=3","gravatar_id":"","url":"https://api.github.com/users/trainerbill","html_url":"https://github.com/trainerbill","followers_url":"https://api.github.com/users/trainerbill/followers","following_url":"https://api.github.com/users/trainerbill/following{/other_user}","gists_url":"https://api.github.com/users/trainerbill/gists{/gist_id}","starred_url":"https://api.github.com/users/trainerbill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trainerbill/subscriptions","organizations_url":"https://api.github.com/users/trainerbill/orgs","repos_url":"https://api.github.com/users/trainerbill/repos","events_url":"https://api.github.com/users/trainerbill/events{/privacy}","received_events_url":"https://api.github.com/users/trainerbill/received_events","type":"User","site_admin":false},"body":"I took a stab at redoing the Authentication in favor of JWT.  I am using passport-jwt to leverage the existing authentication structure.  The Authentication service now holds a user and token and uses localStorage to store the token.  I am only storing the token.  If you refresh the page the AuthService will look for a token in local storage and if it exists hits the users/me route to get the user.  The auth service also sets the $http header for Authorization if the token exists so you don't have to add it to other services.  Currently working:\r\n\r\n1.  Login\r\n2.  Sign Up\r\n3.  Persistent on Refresh and users/me route\r\n4.  Edit Profile\r\n\r\nI want to get buy in from contributors before going any further.  This PR will touch a lot of files and I don't want to get all the way done and someone has a problem and this ends up in PR hell.  If I can get some feedback and +1's I will have this done by Friday this week.  Also would like a volunteer to help fix the tests when this is done and ready.  Thanks to @mleanos for the server side kick start.\r\n\r\n@mleanos @lirantal @ilanbiala @codydaig \r\n\r\nFixes https://github.com/meanjs/mean/issues/389\r\nFixes https://github.com/meanjs/mean/issues/1086\r\n","created_at":"2016-01-26T22:34:25Z","updated_at":"2016-02-05T23:46:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2210154b3092cd8842f04c2f3e197586526b4082","assignee":{"login":"codydaig","id":2314748,"avatar_url":"https://avatars.githubusercontent.com/u/2314748?v=3","gravatar_id":"","url":"https://api.github.com/users/codydaig","html_url":"https://github.com/codydaig","followers_url":"https://api.github.com/users/codydaig/followers","following_url":"https://api.github.com/users/codydaig/following{/other_user}","gists_url":"https://api.github.com/users/codydaig/gists{/gist_id}","starred_url":"https://api.github.com/users/codydaig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codydaig/subscriptions","organizations_url":"https://api.github.com/users/codydaig/orgs","repos_url":"https://api.github.com/users/codydaig/repos","events_url":"https://api.github.com/users/codydaig/events{/privacy}","received_events_url":"https://api.github.com/users/codydaig/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/meanjs/mean/milestones/6","html_url":"https://github.com/meanjs/mean/milestones/0.5.0","labels_url":"https://api.github.com/repos/meanjs/mean/milestones/6/labels","id":1213421,"number":6,"title":"0.5.0","description":"","creator":{"login":"ilanbiala","id":3695164,"avatar_url":"https://avatars.githubusercontent.com/u/3695164?v=3","gravatar_id":"","url":"https://api.github.com/users/ilanbiala","html_url":"https://github.com/ilanbiala","followers_url":"https://api.github.com/users/ilanbiala/followers","following_url":"https://api.github.com/users/ilanbiala/following{/other_user}","gists_url":"https://api.github.com/users/ilanbiala/gists{/gist_id}","starred_url":"https://api.github.com/users/ilanbiala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilanbiala/subscriptions","organizations_url":"https://api.github.com/users/ilanbiala/orgs","repos_url":"https://api.github.com/users/ilanbiala/repos","events_url":"https://api.github.com/users/ilanbiala/events{/privacy}","received_events_url":"https://api.github.com/users/ilanbiala/received_events","type":"User","site_admin":false},"open_issues":27,"closed_issues":67,"state":"open","created_at":"2015-07-17T18:54:42Z","updated_at":"2016-02-05T15:52:03Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/meanjs/mean/pulls/1163/commits","review_comments_url":"https://api.github.com/repos/meanjs/mean/pulls/1163/comments","review_comment_url":"https://api.github.com/repos/meanjs/mean/pulls/comments{/number}","comments_url":"https://api.github.com/repos/meanjs/mean/issues/1163/comments","statuses_url":"https://api.github.com/repos/meanjs/mean/statuses/c3bdd39d1169537340d483be986e93e611ca5f6e","head":{"label":"trainerbill:JWTAuthorization","ref":"JWTAuthorization","sha":"c3bdd39d1169537340d483be986e93e611ca5f6e","user":{"login":"trainerbill","id":3578259,"avatar_url":"https://avatars.githubusercontent.com/u/3578259?v=3","gravatar_id":"","url":"https://api.github.com/users/trainerbill","html_url":"https://github.com/trainerbill","followers_url":"https://api.github.com/users/trainerbill/followers","following_url":"https://api.github.com/users/trainerbill/following{/other_user}","gists_url":"https://api.github.com/users/trainerbill/gists{/gist_id}","starred_url":"https://api.github.com/users/trainerbill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trainerbill/subscriptions","organizations_url":"https://api.github.com/users/trainerbill/orgs","repos_url":"https://api.github.com/users/trainerbill/repos","events_url":"https://api.github.com/users/trainerbill/events{/privacy}","received_events_url":"https://api.github.com/users/trainerbill/received_events","type":"User","site_admin":false},"repo":{"id":35045185,"name":"mean","full_name":"trainerbill/mean","owner":{"login":"trainerbill","id":3578259,"avatar_url":"https://avatars.githubusercontent.com/u/3578259?v=3","gravatar_id":"","url":"https://api.github.com/users/trainerbill","html_url":"https://github.com/trainerbill","followers_url":"https://api.github.com/users/trainerbill/followers","following_url":"https://api.github.com/users/trainerbill/following{/other_user}","gists_url":"https://api.github.com/users/trainerbill/gists{/gist_id}","starred_url":"https://api.github.com/users/trainerbill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trainerbill/subscriptions","organizations_url":"https://api.github.com/users/trainerbill/orgs","repos_url":"https://api.github.com/users/trainerbill/repos","events_url":"https://api.github.com/users/trainerbill/events{/privacy}","received_events_url":"https://api.github.com/users/trainerbill/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/trainerbill/mean","description":"MEAN.JS - Full-Stack JavaScript Using MongoDB, Express, AngularJS, and Node.js - ","fork":true,"url":"https://api.github.com/repos/trainerbill/mean","forks_url":"https://api.github.com/repos/trainerbill/mean/forks","keys_url":"https://api.github.com/repos/trainerbill/mean/keys{/key_id}","collaborators_url":"https://api.github.com/repos/trainerbill/mean/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/trainerbill/mean/teams","hooks_url":"https://api.github.com/repos/trainerbill/mean/hooks","issue_events_url":"https://api.github.com/repos/trainerbill/mean/issues/events{/number}","events_url":"https://api.github.com/repos/trainerbill/mean/events","assignees_url":"https://api.github.com/repos/trainerbill/mean/assignees{/user}","branches_url":"https://api.github.com/repos/trainerbill/mean/branches{/branch}","tags_url":"https://api.github.com/repos/trainerbill/mean/tags","blobs_url":"https://api.github.com/repos/trainerbill/mean/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/trainerbill/mean/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/trainerbill/mean/git/refs{/sha}","trees_url":"https://api.github.com/repos/trainerbill/mean/git/trees{/sha}","statuses_url":"https://api.github.com/repos/trainerbill/mean/statuses/{sha}","languages_url":"https://api.github.com/repos/trainerbill/mean/languages","stargazers_url":"https://api.github.com/repos/trainerbill/mean/stargazers","contributors_url":"https://api.github.com/repos/trainerbill/mean/contributors","subscribers_url":"https://api.github.com/repos/trainerbill/mean/subscribers","subscription_url":"https://api.github.com/repos/trainerbill/mean/subscription","commits_url":"https://api.github.com/repos/trainerbill/mean/commits{/sha}","git_commits_url":"https://api.github.com/repos/trainerbill/mean/git/commits{/sha}","comments_url":"https://api.github.com/repos/trainerbill/mean/comments{/number}","issue_comment_url":"https://api.github.com/repos/trainerbill/mean/issues/comments{/number}","contents_url":"https://api.github.com/repos/trainerbill/mean/contents/{+path}","compare_url":"https://api.github.com/repos/trainerbill/mean/compare/{base}...{head}","merges_url":"https://api.github.com/repos/trainerbill/mean/merges","archive_url":"https://api.github.com/repos/trainerbill/mean/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/trainerbill/mean/downloads","issues_url":"https://api.github.com/repos/trainerbill/mean/issues{/number}","pulls_url":"https://api.github.com/repos/trainerbill/mean/pulls{/number}","milestones_url":"https://api.github.com/repos/trainerbill/mean/milestones{/number}","notifications_url":"https://api.github.com/repos/trainerbill/mean/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/trainerbill/mean/labels{/name}","releases_url":"https://api.github.com/repos/trainerbill/mean/releases{/id}","deployments_url":"https://api.github.com/repos/trainerbill/mean/deployments","created_at":"2015-05-04T16:12:38Z","updated_at":"2016-01-20T01:11:09Z","pushed_at":"2016-02-04T23:30:30Z","git_url":"git://github.com/trainerbill/mean.git","ssh_url":"git@github.com:trainerbill/mean.git","clone_url":"https://github.com/trainerbill/mean.git","svn_url":"https://github.com/trainerbill/mean","homepage":"http://meanjs.org","size":3169,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":0,"forks":3,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"meanjs:master","ref":"master","sha":"e24fd27961560bccef773211093bf55cb7c81a49","user":{"login":"meanjs","id":6232122,"avatar_url":"https://avatars.githubusercontent.com/u/6232122?v=3","gravatar_id":"","url":"https://api.github.com/users/meanjs","html_url":"https://github.com/meanjs","followers_url":"https://api.github.com/users/meanjs/followers","following_url":"https://api.github.com/users/meanjs/following{/other_user}","gists_url":"https://api.github.com/users/meanjs/gists{/gist_id}","starred_url":"https://api.github.com/users/meanjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meanjs/subscriptions","organizations_url":"https://api.github.com/users/meanjs/orgs","repos_url":"https://api.github.com/users/meanjs/repos","events_url":"https://api.github.com/users/meanjs/events{/privacy}","received_events_url":"https://api.github.com/users/meanjs/received_events","type":"Organization","site_admin":false},"repo":{"id":15508537,"name":"mean","full_name":"meanjs/mean","owner":{"login":"meanjs","id":6232122,"avatar_url":"https://avatars.githubusercontent.com/u/6232122?v=3","gravatar_id":"","url":"https://api.github.com/users/meanjs","html_url":"https://github.com/meanjs","followers_url":"https://api.github.com/users/meanjs/followers","following_url":"https://api.github.com/users/meanjs/following{/other_user}","gists_url":"https://api.github.com/users/meanjs/gists{/gist_id}","starred_url":"https://api.github.com/users/meanjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meanjs/subscriptions","organizations_url":"https://api.github.com/users/meanjs/orgs","repos_url":"https://api.github.com/users/meanjs/repos","events_url":"https://api.github.com/users/meanjs/events{/privacy}","received_events_url":"https://api.github.com/users/meanjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/meanjs/mean","description":"MEAN.JS - Full-Stack JavaScript Using MongoDB, Express, AngularJS, and Node.js - ","fork":false,"url":"https://api.github.com/repos/meanjs/mean","forks_url":"https://api.github.com/repos/meanjs/mean/forks","keys_url":"https://api.github.com/repos/meanjs/mean/keys{/key_id}","collaborators_url":"https://api.github.com/repos/meanjs/mean/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/meanjs/mean/teams","hooks_url":"https://api.github.com/repos/meanjs/mean/hooks","issue_events_url":"https://api.github.com/repos/meanjs/mean/issues/events{/number}","events_url":"https://api.github.com/repos/meanjs/mean/events","assignees_url":"https://api.github.com/repos/meanjs/mean/assignees{/user}","branches_url":"https://api.github.com/repos/meanjs/mean/branches{/branch}","tags_url":"https://api.github.com/repos/meanjs/mean/tags","blobs_url":"https://api.github.com/repos/meanjs/mean/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/meanjs/mean/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/meanjs/mean/git/refs{/sha}","trees_url":"https://api.github.com/repos/meanjs/mean/git/trees{/sha}","statuses_url":"https://api.github.com/repos/meanjs/mean/statuses/{sha}","languages_url":"https://api.github.com/repos/meanjs/mean/languages","stargazers_url":"https://api.github.com/repos/meanjs/mean/stargazers","contributors_url":"https://api.github.com/repos/meanjs/mean/contributors","subscribers_url":"https://api.github.com/repos/meanjs/mean/subscribers","subscription_url":"https://api.github.com/repos/meanjs/mean/subscription","commits_url":"https://api.github.com/repos/meanjs/mean/commits{/sha}","git_commits_url":"https://api.github.com/repos/meanjs/mean/git/commits{/sha}","comments_url":"https://api.github.com/repos/meanjs/mean/comments{/number}","issue_comment_url":"https://api.github.com/repos/meanjs/mean/issues/comments{/number}","contents_url":"https://api.github.com/repos/meanjs/mean/contents/{+path}","compare_url":"https://api.github.com/repos/meanjs/mean/compare/{base}...{head}","merges_url":"https://api.github.com/repos/meanjs/mean/merges","archive_url":"https://api.github.com/repos/meanjs/mean/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/meanjs/mean/downloads","issues_url":"https://api.github.com/repos/meanjs/mean/issues{/number}","pulls_url":"https://api.github.com/repos/meanjs/mean/pulls{/number}","milestones_url":"https://api.github.com/repos/meanjs/mean/milestones{/number}","notifications_url":"https://api.github.com/repos/meanjs/mean/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/meanjs/mean/labels{/name}","releases_url":"https://api.github.com/repos/meanjs/mean/releases{/id}","deployments_url":"https://api.github.com/repos/meanjs/mean/deployments","created_at":"2013-12-29T13:01:15Z","updated_at":"2016-02-05T22:45:46Z","pushed_at":"2016-02-05T03:54:01Z","git_url":"git://github.com/meanjs/mean.git","ssh_url":"git@github.com:meanjs/mean.git","clone_url":"https://github.com/meanjs/mean.git","svn_url":"https://github.com/meanjs/mean","homepage":"http://meanjs.org","size":5102,"stargazers_count":3064,"watchers_count":3064,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1178,"mirror_url":null,"open_issues_count":75,"forks":1178,"open_issues":75,"watchers":3064,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/meanjs/mean/pulls/1163"},"html":{"href":"https://github.com/meanjs/mean/pull/1163"},"issue":{"href":"https://api.github.com/repos/meanjs/mean/issues/1163"},"comments":{"href":"https://api.github.com/repos/meanjs/mean/issues/1163/comments"},"review_comments":{"href":"https://api.github.com/repos/meanjs/mean/pulls/1163/comments"},"review_comment":{"href":"https://api.github.com/repos/meanjs/mean/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/meanjs/mean/pulls/1163/commits"},"statuses":{"href":"https://api.github.com/repos/meanjs/mean/statuses/c3bdd39d1169537340d483be986e93e611ca5f6e"}}}}