{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/mercury/pulls/comments/39490103","id":39490103,"diff_hunk":"@@ -0,0 +1,70 @@\n+/**\n+ * Wikia (Japan) Homepage\n+ *\n+ * @author Per Johan Groland <pgroland@wikia-inc.com>\n+ */\n+\n+var Promise = require('bluebird'),\n+\trequest = require('request'),\n+\tlocalSettings = require('../config/localSettings').localSettings;\n+\n+function Auth() {\n+\tthis.baseUrl = localSettings.helios.host;\n+\tthis.servicesUrl = localSettings.servicesUrl;\n+}\n+\n+function requestWrapper(url) {\n+\tvar deferred = Promise.defer();\n+\n+\trequest.get(url, function (err, response, body) {\n+\t\tif (err) {\n+\t\t\tdeferred.reject(err);\n+\t\t} else {\n+\t\t\ttry {\n+\t\t\t\tvar json = JSON.parse(body);\n+\n+\t\t\t\tif (json.error) {\n+\t\t\t\t\tdeferred.reject(json);\n+\t\t\t\t} else {\n+\t\t\t\t\tdeferred.resolve(json);\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tcatch (e) {\n+\t\t\t\tdeferred.resolve(body);\n+\t\t\t}\n+\t\t}\n+\t});\n+\n+\treturn deferred.promise;\n+}\n+\n+Auth.prototype.login = function (username, password) {\n+\tvar url = this.baseUrl + 'token?' +\n+\t\t'username=' + username + '&' +\n+\t\t'password=' + password;\n+\n+\treturn requestWrapper(url);\n+};\n+\n+Auth.prototype.info = function (token) {\n+\tvar url = this.baseUrl + 'info?' +\n+\t\t'code=' + token;\n+\n+\treturn requestWrapper(url);\n+};\n+\n+Auth.prototype.validateUser = function (username) {\n+\tvar url = this.baseUrl + 'username/validation?' +\n+\t\t'username=' + username;\n+\n+\treturn requestWrapper(url);\n+};\n+\n+Auth.prototype.getUserName = function (heliosInfoResponse) {\n+\tvar url = this.servicesUrl + 'user-attribute/user/' +\n+\t\theliosInfoResponse.user_id  + '/attr/username'; // jshint ignore:line","path":"homepage/server/auth.js","position":65,"original_position":65,"commit_id":"4e729d8c5acfe50ede9e711d76534853c53c1817","original_commit_id":"4e729d8c5acfe50ede9e711d76534853c53c1817","user":{"login":"bkoval","id":2035428,"avatar_url":"https://avatars.githubusercontent.com/u/2035428?v=3","gravatar_id":"","url":"https://api.github.com/users/bkoval","html_url":"https://github.com/bkoval","followers_url":"https://api.github.com/users/bkoval/followers","following_url":"https://api.github.com/users/bkoval/following{/other_user}","gists_url":"https://api.github.com/users/bkoval/gists{/gist_id}","starred_url":"https://api.github.com/users/bkoval/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkoval/subscriptions","organizations_url":"https://api.github.com/users/bkoval/orgs","repos_url":"https://api.github.com/users/bkoval/repos","events_url":"https://api.github.com/users/bkoval/events{/privacy}","received_events_url":"https://api.github.com/users/bkoval/received_events","type":"User","site_admin":false},"body":"Would jshint shout if you'd call heliosInfoResponse['user_id'] instead?","created_at":"2015-09-15T09:23:39Z","updated_at":"2015-09-15T09:23:39Z","html_url":"https://github.com/Wikia/mercury/pull/1363#discussion_r39490103","pull_request_url":"https://api.github.com/repos/Wikia/mercury/pulls/1363","_links":{"self":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/comments/39490103"},"html":{"href":"https://github.com/Wikia/mercury/pull/1363#discussion_r39490103"},"pull_request":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/1363"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/mercury/pulls/1363","id":45004839,"html_url":"https://github.com/Wikia/mercury/pull/1363","diff_url":"https://github.com/Wikia/mercury/pull/1363.diff","patch_url":"https://github.com/Wikia/mercury/pull/1363.patch","issue_url":"https://api.github.com/repos/Wikia/mercury/issues/1363","number":1363,"state":"open","locked":false,"title":"INT-136: Login state support for Japan homepage","user":{"login":"perjg","id":651004,"avatar_url":"https://avatars.githubusercontent.com/u/651004?v=3","gravatar_id":"","url":"https://api.github.com/users/perjg","html_url":"https://github.com/perjg","followers_url":"https://api.github.com/users/perjg/followers","following_url":"https://api.github.com/users/perjg/following{/other_user}","gists_url":"https://api.github.com/users/perjg/gists{/gist_id}","starred_url":"https://api.github.com/users/perjg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/perjg/subscriptions","organizations_url":"https://api.github.com/users/perjg/orgs","repos_url":"https://api.github.com/users/perjg/repos","events_url":"https://api.github.com/users/perjg/events{/privacy}","received_events_url":"https://api.github.com/users/perjg/received_events","type":"User","site_admin":false},"body":"Read helios access_token cookie, and then call info to get token validity. Also use the return value from info to translate user id into user name.\r\n\r\nRefactored facets to all use the auth_token cookie.\r\n\r\nMissing: Requests are made every time. Should store user name into session cookie. Will do this in separate PR. ","created_at":"2015-09-15T03:16:12Z","updated_at":"2015-09-15T09:23:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"657d81ab6590f34baff45a7d3642f47be77e703c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/mercury/pulls/1363/commits","review_comments_url":"https://api.github.com/repos/Wikia/mercury/pulls/1363/comments","review_comment_url":"https://api.github.com/repos/Wikia/mercury/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/mercury/issues/1363/comments","statuses_url":"https://api.github.com/repos/Wikia/mercury/statuses/4e729d8c5acfe50ede9e711d76534853c53c1817","head":{"label":"Wikia:INT-136-3","ref":"INT-136-3","sha":"4e729d8c5acfe50ede9e711d76534853c53c1817","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":16710430,"name":"mercury","full_name":"Wikia/mercury","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/mercury","description":"Wikia Web application","fork":false,"url":"https://api.github.com/repos/Wikia/mercury","forks_url":"https://api.github.com/repos/Wikia/mercury/forks","keys_url":"https://api.github.com/repos/Wikia/mercury/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/mercury/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/mercury/teams","hooks_url":"https://api.github.com/repos/Wikia/mercury/hooks","issue_events_url":"https://api.github.com/repos/Wikia/mercury/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/mercury/events","assignees_url":"https://api.github.com/repos/Wikia/mercury/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/mercury/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/mercury/tags","blobs_url":"https://api.github.com/repos/Wikia/mercury/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/mercury/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/mercury/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/mercury/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/mercury/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/mercury/languages","stargazers_url":"https://api.github.com/repos/Wikia/mercury/stargazers","contributors_url":"https://api.github.com/repos/Wikia/mercury/contributors","subscribers_url":"https://api.github.com/repos/Wikia/mercury/subscribers","subscription_url":"https://api.github.com/repos/Wikia/mercury/subscription","commits_url":"https://api.github.com/repos/Wikia/mercury/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/mercury/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/mercury/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/mercury/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/mercury/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/mercury/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/mercury/merges","archive_url":"https://api.github.com/repos/Wikia/mercury/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/mercury/downloads","issues_url":"https://api.github.com/repos/Wikia/mercury/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/mercury/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/mercury/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/mercury/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/mercury/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/mercury/releases{/id}","created_at":"2014-02-10T21:44:25Z","updated_at":"2015-09-08T00:21:11Z","pushed_at":"2015-09-15T08:45:09Z","git_url":"git://github.com/Wikia/mercury.git","ssh_url":"git@github.com:Wikia/mercury.git","clone_url":"https://github.com/Wikia/mercury.git","svn_url":"https://github.com/Wikia/mercury","homepage":"","size":63233,"stargazers_count":12,"watchers_count":12,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":12,"forks":1,"open_issues":12,"watchers":12,"default_branch":"dev"}},"base":{"label":"Wikia:dev","ref":"dev","sha":"2235d46d9e18bbf61b35fc03edf04d97c2a7effd","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":16710430,"name":"mercury","full_name":"Wikia/mercury","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/mercury","description":"Wikia Web application","fork":false,"url":"https://api.github.com/repos/Wikia/mercury","forks_url":"https://api.github.com/repos/Wikia/mercury/forks","keys_url":"https://api.github.com/repos/Wikia/mercury/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/mercury/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/mercury/teams","hooks_url":"https://api.github.com/repos/Wikia/mercury/hooks","issue_events_url":"https://api.github.com/repos/Wikia/mercury/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/mercury/events","assignees_url":"https://api.github.com/repos/Wikia/mercury/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/mercury/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/mercury/tags","blobs_url":"https://api.github.com/repos/Wikia/mercury/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/mercury/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/mercury/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/mercury/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/mercury/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/mercury/languages","stargazers_url":"https://api.github.com/repos/Wikia/mercury/stargazers","contributors_url":"https://api.github.com/repos/Wikia/mercury/contributors","subscribers_url":"https://api.github.com/repos/Wikia/mercury/subscribers","subscription_url":"https://api.github.com/repos/Wikia/mercury/subscription","commits_url":"https://api.github.com/repos/Wikia/mercury/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/mercury/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/mercury/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/mercury/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/mercury/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/mercury/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/mercury/merges","archive_url":"https://api.github.com/repos/Wikia/mercury/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/mercury/downloads","issues_url":"https://api.github.com/repos/Wikia/mercury/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/mercury/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/mercury/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/mercury/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/mercury/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/mercury/releases{/id}","created_at":"2014-02-10T21:44:25Z","updated_at":"2015-09-08T00:21:11Z","pushed_at":"2015-09-15T08:45:09Z","git_url":"git://github.com/Wikia/mercury.git","ssh_url":"git@github.com:Wikia/mercury.git","clone_url":"https://github.com/Wikia/mercury.git","svn_url":"https://github.com/Wikia/mercury","homepage":"","size":63233,"stargazers_count":12,"watchers_count":12,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":12,"forks":1,"open_issues":12,"watchers":12,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/1363"},"html":{"href":"https://github.com/Wikia/mercury/pull/1363"},"issue":{"href":"https://api.github.com/repos/Wikia/mercury/issues/1363"},"comments":{"href":"https://api.github.com/repos/Wikia/mercury/issues/1363/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/1363/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/1363/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/mercury/statuses/4e729d8c5acfe50ede9e711d76534853c53c1817"}}}}