{"action":"created","comment":{"url":"https://api.github.com/repos/linnovate/mean/pulls/comments/38584502","id":38584502,"diff_hunk":"@@ -58,33 +59,21 @@ angular.module('mean.users').factory('MeanUser', [ '$rootScope', '$http', '$loca\n     }\n \n     MeanUserKlass.prototype.onIdentity = function(response) {\n-      this.loginError = 0;\n-      this.loggedin = true;\n-      this.registerError = 0;\n-      if (!response) {\n-        this.user = {};\n-        this.loggedin = false;\n-        this.isAdmin = false;\n-      } else if(angular.isDefined(response.token)) {\n-        localStorage.setItem('JWT', response.token);\n-        var encodedProfile = decodeURI(b64_to_utf8(response.token.split('.')[1]));\n-        var payload = JSON.parse(encodedProfile);\n-        this.user = payload;\n-        var destination = $cookies.get('redirect');\n-        if (this.user.roles.indexOf('admin') !== -1) this.isAdmin = true;\n-        $rootScope.$emit('loggedin');\n-        if (destination) {\n-          $location.path(destination.replace(/^\"|\"$/g, ''));\n-          $cookies.remove('redirect');\n-        } else {\n-          $location.url('/');\n+        if (!response) return;\n+        var encodedUser, user, destination;\n+        if (angular.isDefined(response.token)) {\n+            localStorage.setItem('JWT', response.token);\n+            encodedUser = decodeURI(b64_to_utf8(response.token.split('.')[1]));\n+            user = JSON.parse(encodedUser); \n         }\n-      } else {\n-        this.user = response;\n+        destination = angular.isDefined(response.redirect) ? response.redirect : null;\n+        this.user = user || response;\n         this.loggedin = true;\n-        if (this.user.roles.indexOf('admin') !== -1) this.isAdmin = true;\n+        this.loginError = 0;\n+        this.registerError = 0;\n+        this.isAdmin = !! (this.user.roles.indexOf('admin') + 1);","path":"packages/core/users/public/services/meanUser.js","position":52,"original_position":52,"commit_id":"86f9cc9a6599f231bbcc2228124100ccf7373ef0","original_commit_id":"86f9cc9a6599f231bbcc2228124100ccf7373ef0","user":{"login":"rjVapes","id":1992658,"avatar_url":"https://avatars.githubusercontent.com/u/1992658?v=3","gravatar_id":"","url":"https://api.github.com/users/rjVapes","html_url":"https://github.com/rjVapes","followers_url":"https://api.github.com/users/rjVapes/followers","following_url":"https://api.github.com/users/rjVapes/following{/other_user}","gists_url":"https://api.github.com/users/rjVapes/gists{/gist_id}","starred_url":"https://api.github.com/users/rjVapes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjVapes/subscriptions","organizations_url":"https://api.github.com/users/rjVapes/orgs","repos_url":"https://api.github.com/users/rjVapes/repos","events_url":"https://api.github.com/users/rjVapes/events{/privacy}","received_events_url":"https://api.github.com/users/rjVapes/received_events","type":"User","site_admin":false},"body":"I actually agree with hound for once.  This could probably be more clear.","created_at":"2015-09-02T21:07:22Z","updated_at":"2015-09-02T21:07:22Z","html_url":"https://github.com/linnovate/mean/pull/1329#discussion_r38584502","pull_request_url":"https://api.github.com/repos/linnovate/mean/pulls/1329","_links":{"self":{"href":"https://api.github.com/repos/linnovate/mean/pulls/comments/38584502"},"html":{"href":"https://github.com/linnovate/mean/pull/1329#discussion_r38584502"},"pull_request":{"href":"https://api.github.com/repos/linnovate/mean/pulls/1329"}}},"pull_request":{"url":"https://api.github.com/repos/linnovate/mean/pulls/1329","id":43873360,"html_url":"https://github.com/linnovate/mean/pull/1329","diff_url":"https://github.com/linnovate/mean/pull/1329.diff","patch_url":"https://github.com/linnovate/mean/pull/1329.patch","issue_url":"https://api.github.com/repos/linnovate/mean/issues/1329","number":1329,"state":"open","locked":false,"title":"some clean update and fix","user":{"login":"emps","id":2281169,"avatar_url":"https://avatars.githubusercontent.com/u/2281169?v=3","gravatar_id":"","url":"https://api.github.com/users/emps","html_url":"https://github.com/emps","followers_url":"https://api.github.com/users/emps/followers","following_url":"https://api.github.com/users/emps/following{/other_user}","gists_url":"https://api.github.com/users/emps/gists{/gist_id}","starred_url":"https://api.github.com/users/emps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emps/subscriptions","organizations_url":"https://api.github.com/users/emps/orgs","repos_url":"https://api.github.com/users/emps/repos","events_url":"https://api.github.com/users/emps/events{/privacy}","received_events_url":"https://api.github.com/users/emps/received_events","type":"User","site_admin":false},"body":"fix for the problem with redirecting to '/' any time refreshing the page while user gets new jwt or get updated..","created_at":"2015-09-01T13:11:26Z","updated_at":"2015-09-02T21:07:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"24c24c5180bc2b2f1d59e30616ab36fa39de3fa0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/linnovate/mean/pulls/1329/commits","review_comments_url":"https://api.github.com/repos/linnovate/mean/pulls/1329/comments","review_comment_url":"https://api.github.com/repos/linnovate/mean/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linnovate/mean/issues/1329/comments","statuses_url":"https://api.github.com/repos/linnovate/mean/statuses/86f9cc9a6599f231bbcc2228124100ccf7373ef0","head":{"label":"emps:patch-8","ref":"patch-8","sha":"86f9cc9a6599f231bbcc2228124100ccf7373ef0","user":{"login":"emps","id":2281169,"avatar_url":"https://avatars.githubusercontent.com/u/2281169?v=3","gravatar_id":"","url":"https://api.github.com/users/emps","html_url":"https://github.com/emps","followers_url":"https://api.github.com/users/emps/followers","following_url":"https://api.github.com/users/emps/following{/other_user}","gists_url":"https://api.github.com/users/emps/gists{/gist_id}","starred_url":"https://api.github.com/users/emps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emps/subscriptions","organizations_url":"https://api.github.com/users/emps/orgs","repos_url":"https://api.github.com/users/emps/repos","events_url":"https://api.github.com/users/emps/events{/privacy}","received_events_url":"https://api.github.com/users/emps/received_events","type":"User","site_admin":false},"repo":{"id":39913872,"name":"mean","full_name":"emps/mean","owner":{"login":"emps","id":2281169,"avatar_url":"https://avatars.githubusercontent.com/u/2281169?v=3","gravatar_id":"","url":"https://api.github.com/users/emps","html_url":"https://github.com/emps","followers_url":"https://api.github.com/users/emps/followers","following_url":"https://api.github.com/users/emps/following{/other_user}","gists_url":"https://api.github.com/users/emps/gists{/gist_id}","starred_url":"https://api.github.com/users/emps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emps/subscriptions","organizations_url":"https://api.github.com/users/emps/orgs","repos_url":"https://api.github.com/users/emps/repos","events_url":"https://api.github.com/users/emps/events{/privacy}","received_events_url":"https://api.github.com/users/emps/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/emps/mean","description":"MEAN (Mongo, Express, Angular, Node) - A Simple, Scalable and Easy starting point for full stack javascript web development - utilizing many of the best practices we've found on the way","fork":true,"url":"https://api.github.com/repos/emps/mean","forks_url":"https://api.github.com/repos/emps/mean/forks","keys_url":"https://api.github.com/repos/emps/mean/keys{/key_id}","collaborators_url":"https://api.github.com/repos/emps/mean/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/emps/mean/teams","hooks_url":"https://api.github.com/repos/emps/mean/hooks","issue_events_url":"https://api.github.com/repos/emps/mean/issues/events{/number}","events_url":"https://api.github.com/repos/emps/mean/events","assignees_url":"https://api.github.com/repos/emps/mean/assignees{/user}","branches_url":"https://api.github.com/repos/emps/mean/branches{/branch}","tags_url":"https://api.github.com/repos/emps/mean/tags","blobs_url":"https://api.github.com/repos/emps/mean/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/emps/mean/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/emps/mean/git/refs{/sha}","trees_url":"https://api.github.com/repos/emps/mean/git/trees{/sha}","statuses_url":"https://api.github.com/repos/emps/mean/statuses/{sha}","languages_url":"https://api.github.com/repos/emps/mean/languages","stargazers_url":"https://api.github.com/repos/emps/mean/stargazers","contributors_url":"https://api.github.com/repos/emps/mean/contributors","subscribers_url":"https://api.github.com/repos/emps/mean/subscribers","subscription_url":"https://api.github.com/repos/emps/mean/subscription","commits_url":"https://api.github.com/repos/emps/mean/commits{/sha}","git_commits_url":"https://api.github.com/repos/emps/mean/git/commits{/sha}","comments_url":"https://api.github.com/repos/emps/mean/comments{/number}","issue_comment_url":"https://api.github.com/repos/emps/mean/issues/comments{/number}","contents_url":"https://api.github.com/repos/emps/mean/contents/{+path}","compare_url":"https://api.github.com/repos/emps/mean/compare/{base}...{head}","merges_url":"https://api.github.com/repos/emps/mean/merges","archive_url":"https://api.github.com/repos/emps/mean/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/emps/mean/downloads","issues_url":"https://api.github.com/repos/emps/mean/issues{/number}","pulls_url":"https://api.github.com/repos/emps/mean/pulls{/number}","milestones_url":"https://api.github.com/repos/emps/mean/milestones{/number}","notifications_url":"https://api.github.com/repos/emps/mean/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/emps/mean/labels{/name}","releases_url":"https://api.github.com/repos/emps/mean/releases{/id}","created_at":"2015-07-29T20:09:55Z","updated_at":"2015-07-29T20:09:57Z","pushed_at":"2015-09-01T13:11:09Z","git_url":"git://github.com/emps/mean.git","ssh_url":"git@github.com:emps/mean.git","clone_url":"https://github.com/emps/mean.git","svn_url":"https://github.com/emps/mean","homepage":"http://mean.io","size":7179,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"linnovate:master","ref":"master","sha":"336304f5590c93e2ca128c5deaabb0de970f8182","user":{"login":"linnovate","id":307487,"avatar_url":"https://avatars.githubusercontent.com/u/307487?v=3","gravatar_id":"","url":"https://api.github.com/users/linnovate","html_url":"https://github.com/linnovate","followers_url":"https://api.github.com/users/linnovate/followers","following_url":"https://api.github.com/users/linnovate/following{/other_user}","gists_url":"https://api.github.com/users/linnovate/gists{/gist_id}","starred_url":"https://api.github.com/users/linnovate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linnovate/subscriptions","organizations_url":"https://api.github.com/users/linnovate/orgs","repos_url":"https://api.github.com/users/linnovate/repos","events_url":"https://api.github.com/users/linnovate/events{/privacy}","received_events_url":"https://api.github.com/users/linnovate/received_events","type":"Organization","site_admin":false},"repo":{"id":10219106,"name":"mean","full_name":"linnovate/mean","owner":{"login":"linnovate","id":307487,"avatar_url":"https://avatars.githubusercontent.com/u/307487?v=3","gravatar_id":"","url":"https://api.github.com/users/linnovate","html_url":"https://github.com/linnovate","followers_url":"https://api.github.com/users/linnovate/followers","following_url":"https://api.github.com/users/linnovate/following{/other_user}","gists_url":"https://api.github.com/users/linnovate/gists{/gist_id}","starred_url":"https://api.github.com/users/linnovate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linnovate/subscriptions","organizations_url":"https://api.github.com/users/linnovate/orgs","repos_url":"https://api.github.com/users/linnovate/repos","events_url":"https://api.github.com/users/linnovate/events{/privacy}","received_events_url":"https://api.github.com/users/linnovate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linnovate/mean","description":"MEAN (Mongo, Express, Angular, Node) - A Simple, Scalable and Easy starting point for full stack javascript web development - utilizing many of the best practices we've found on the way","fork":false,"url":"https://api.github.com/repos/linnovate/mean","forks_url":"https://api.github.com/repos/linnovate/mean/forks","keys_url":"https://api.github.com/repos/linnovate/mean/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linnovate/mean/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linnovate/mean/teams","hooks_url":"https://api.github.com/repos/linnovate/mean/hooks","issue_events_url":"https://api.github.com/repos/linnovate/mean/issues/events{/number}","events_url":"https://api.github.com/repos/linnovate/mean/events","assignees_url":"https://api.github.com/repos/linnovate/mean/assignees{/user}","branches_url":"https://api.github.com/repos/linnovate/mean/branches{/branch}","tags_url":"https://api.github.com/repos/linnovate/mean/tags","blobs_url":"https://api.github.com/repos/linnovate/mean/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linnovate/mean/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linnovate/mean/git/refs{/sha}","trees_url":"https://api.github.com/repos/linnovate/mean/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linnovate/mean/statuses/{sha}","languages_url":"https://api.github.com/repos/linnovate/mean/languages","stargazers_url":"https://api.github.com/repos/linnovate/mean/stargazers","contributors_url":"https://api.github.com/repos/linnovate/mean/contributors","subscribers_url":"https://api.github.com/repos/linnovate/mean/subscribers","subscription_url":"https://api.github.com/repos/linnovate/mean/subscription","commits_url":"https://api.github.com/repos/linnovate/mean/commits{/sha}","git_commits_url":"https://api.github.com/repos/linnovate/mean/git/commits{/sha}","comments_url":"https://api.github.com/repos/linnovate/mean/comments{/number}","issue_comment_url":"https://api.github.com/repos/linnovate/mean/issues/comments{/number}","contents_url":"https://api.github.com/repos/linnovate/mean/contents/{+path}","compare_url":"https://api.github.com/repos/linnovate/mean/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linnovate/mean/merges","archive_url":"https://api.github.com/repos/linnovate/mean/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linnovate/mean/downloads","issues_url":"https://api.github.com/repos/linnovate/mean/issues{/number}","pulls_url":"https://api.github.com/repos/linnovate/mean/pulls{/number}","milestones_url":"https://api.github.com/repos/linnovate/mean/milestones{/number}","notifications_url":"https://api.github.com/repos/linnovate/mean/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linnovate/mean/labels{/name}","releases_url":"https://api.github.com/repos/linnovate/mean/releases{/id}","created_at":"2013-05-22T12:15:47Z","updated_at":"2015-09-02T20:10:24Z","pushed_at":"2015-09-01T16:46:28Z","git_url":"git://github.com/linnovate/mean.git","ssh_url":"git@github.com:linnovate/mean.git","clone_url":"https://github.com/linnovate/mean.git","svn_url":"https://github.com/linnovate/mean","homepage":"http://mean.io","size":14197,"stargazers_count":7331,"watchers_count":7331,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2197,"mirror_url":null,"open_issues_count":273,"forks":2197,"open_issues":273,"watchers":7331,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linnovate/mean/pulls/1329"},"html":{"href":"https://github.com/linnovate/mean/pull/1329"},"issue":{"href":"https://api.github.com/repos/linnovate/mean/issues/1329"},"comments":{"href":"https://api.github.com/repos/linnovate/mean/issues/1329/comments"},"review_comments":{"href":"https://api.github.com/repos/linnovate/mean/pulls/1329/comments"},"review_comment":{"href":"https://api.github.com/repos/linnovate/mean/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linnovate/mean/pulls/1329/commits"},"statuses":{"href":"https://api.github.com/repos/linnovate/mean/statuses/86f9cc9a6599f231bbcc2228124100ccf7373ef0"}}}}