{"action":"created","comment":{"url":"https://api.github.com/repos/LearnersGuild/echo/pulls/comments/129618615","pull_request_review_id":52406660,"id":129618615,"diff_hunk":"@@ -20,7 +20,13 @@ const toureiroApp = toureiro({\n app.use(\n   '/job-queues',\n   (req, res, next) => {\n-    if (!req.user || !userCan(req.user, 'monitorJobQueues')) {\n+    const baseUrl = req.baseUrl\n+    const encodedURI = encodeURIComponent(`${process.env.APP_BASE_URL}${baseUrl}`)\n+\n+    if (!req.user) {\n+      res.redirect(`${process.env.IDM_BASE_URL}/sign-in?redirect=${encodedURI}`)","path":"src/server/jobQueuesUI.js","position":9,"original_position":9,"commit_id":"80e4d0839cc21df0333feb0c88a0983392eaea60","original_commit_id":"80e4d0839cc21df0333feb0c88a0983392eaea60","user":{"login":"prattsj","id":1890882,"avatar_url":"https://avatars2.githubusercontent.com/u/1890882?v=4","gravatar_id":"","url":"https://api.github.com/users/prattsj","html_url":"https://github.com/prattsj","followers_url":"https://api.github.com/users/prattsj/followers","following_url":"https://api.github.com/users/prattsj/following{/other_user}","gists_url":"https://api.github.com/users/prattsj/gists{/gist_id}","starred_url":"https://api.github.com/users/prattsj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prattsj/subscriptions","organizations_url":"https://api.github.com/users/prattsj/orgs","repos_url":"https://api.github.com/users/prattsj/repos","events_url":"https://api.github.com/users/prattsj/events{/privacy}","received_events_url":"https://api.github.com/users/prattsj/received_events","type":"User","site_admin":false},"body":"This same URL is also composed in `src/common/routes/index.jsx`. Let's pull it into a util function used both here and there, perhaps in a module `src/common/util/auth.js`.\r\n\r\nWe also want the user to be redirected _back_ to the job queues path instead of to home/root as it's currently doing here.\r\n\r\nYou might wanna have something like:\r\n```js\r\n// in src/common/util/auth.js\r\nexport function loginURL(options = {}) {\r\n  const redirect = options.redirect ? `?redirect=${encodeURIComponent(options.redirect)}` : ''\r\n  return `${process.env.IDM_BASE_URL}/sign-in${redirect}`\r\n}\r\n```\r\n\r\nAnd then do:\r\n```js\r\n// in src/server/jobQueuesUI.js\r\nimport {loginURL} from 'src/common/util/auth'\r\n...\r\nif (!req.user) {\r\n  const redirectUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`\r\n  res.redirect(loginUrl({redirect: redirectUrl}))\r\n}\r\n...\r\n```\r\n\r\n```js\r\n// in src/common/routes/index.jsx\r\nimport {loginURL} from 'src/common/util/auth'\r\n...\r\n    if (typeof window !== 'undefined' && window.location) {\r\n      window.location.href = loginURL({redirect: window.location.href})\r\n    }\r\n...\r\n```","created_at":"2017-07-26T16:08:11Z","updated_at":"2017-07-26T16:08:50Z","html_url":"https://github.com/LearnersGuild/echo/pull/1052#discussion_r129618615","pull_request_url":"https://api.github.com/repos/LearnersGuild/echo/pulls/1052","_links":{"self":{"href":"https://api.github.com/repos/LearnersGuild/echo/pulls/comments/129618615"},"html":{"href":"https://github.com/LearnersGuild/echo/pull/1052#discussion_r129618615"},"pull_request":{"href":"https://api.github.com/repos/LearnersGuild/echo/pulls/1052"}}},"pull_request":{"url":"https://api.github.com/repos/LearnersGuild/echo/pulls/1052","id":132348025,"html_url":"https://github.com/LearnersGuild/echo/pull/1052","diff_url":"https://github.com/LearnersGuild/echo/pull/1052.diff","patch_url":"https://github.com/LearnersGuild/echo/pull/1052.patch","issue_url":"https://api.github.com/repos/LearnersGuild/echo/issues/1052","number":1052,"state":"open","locked":false,"title":"Redirects user to login if not authenticated","user":{"login":"sdweber422","id":11862202,"avatar_url":"https://avatars1.githubusercontent.com/u/11862202?v=4","gravatar_id":"","url":"https://api.github.com/users/sdweber422","html_url":"https://github.com/sdweber422","followers_url":"https://api.github.com/users/sdweber422/followers","following_url":"https://api.github.com/users/sdweber422/following{/other_user}","gists_url":"https://api.github.com/users/sdweber422/gists{/gist_id}","starred_url":"https://api.github.com/users/sdweber422/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdweber422/subscriptions","organizations_url":"https://api.github.com/users/sdweber422/orgs","repos_url":"https://api.github.com/users/sdweber422/repos","events_url":"https://api.github.com/users/sdweber422/events{/privacy}","received_events_url":"https://api.github.com/users/sdweber422/received_events","type":"User","site_admin":false},"body":"Fixes #981 \r\n\r\n## Overview\r\n\r\nRedirects the user to login if not authenticated when requesting /job-queues instead of returning a 500 code.\r\n\r\n## Data Model / DB Schema Changes\r\n\r\nNone.\r\n\r\n## Environment / Configuration Changes\r\n\r\nNone.\r\n\r\n## Notes\r\n\r\nProvided redirect back to /job-queues.","created_at":"2017-07-25T18:24:34Z","updated_at":"2017-07-26T16:08:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"258c5dfb26bc28b1bdde551a79852d957ba15153","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/LearnersGuild/echo/pulls/1052/commits","review_comments_url":"https://api.github.com/repos/LearnersGuild/echo/pulls/1052/comments","review_comment_url":"https://api.github.com/repos/LearnersGuild/echo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LearnersGuild/echo/issues/1052/comments","statuses_url":"https://api.github.com/repos/LearnersGuild/echo/statuses/80e4d0839cc21df0333feb0c88a0983392eaea60","head":{"label":"sdweber422:981","ref":"981","sha":"80e4d0839cc21df0333feb0c88a0983392eaea60","user":{"login":"sdweber422","id":11862202,"avatar_url":"https://avatars1.githubusercontent.com/u/11862202?v=4","gravatar_id":"","url":"https://api.github.com/users/sdweber422","html_url":"https://github.com/sdweber422","followers_url":"https://api.github.com/users/sdweber422/followers","following_url":"https://api.github.com/users/sdweber422/following{/other_user}","gists_url":"https://api.github.com/users/sdweber422/gists{/gist_id}","starred_url":"https://api.github.com/users/sdweber422/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdweber422/subscriptions","organizations_url":"https://api.github.com/users/sdweber422/orgs","repos_url":"https://api.github.com/users/sdweber422/repos","events_url":"https://api.github.com/users/sdweber422/events{/privacy}","received_events_url":"https://api.github.com/users/sdweber422/received_events","type":"User","site_admin":false},"repo":{"id":95914572,"name":"echo","full_name":"sdweber422/echo","owner":{"login":"sdweber422","id":11862202,"avatar_url":"https://avatars1.githubusercontent.com/u/11862202?v=4","gravatar_id":"","url":"https://api.github.com/users/sdweber422","html_url":"https://github.com/sdweber422","followers_url":"https://api.github.com/users/sdweber422/followers","following_url":"https://api.github.com/users/sdweber422/following{/other_user}","gists_url":"https://api.github.com/users/sdweber422/gists{/gist_id}","starred_url":"https://api.github.com/users/sdweber422/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdweber422/subscriptions","organizations_url":"https://api.github.com/users/sdweber422/orgs","repos_url":"https://api.github.com/users/sdweber422/repos","events_url":"https://api.github.com/users/sdweber422/events{/privacy}","received_events_url":"https://api.github.com/users/sdweber422/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sdweber422/echo","description":"echo: learning management system","fork":true,"url":"https://api.github.com/repos/sdweber422/echo","forks_url":"https://api.github.com/repos/sdweber422/echo/forks","keys_url":"https://api.github.com/repos/sdweber422/echo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sdweber422/echo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sdweber422/echo/teams","hooks_url":"https://api.github.com/repos/sdweber422/echo/hooks","issue_events_url":"https://api.github.com/repos/sdweber422/echo/issues/events{/number}","events_url":"https://api.github.com/repos/sdweber422/echo/events","assignees_url":"https://api.github.com/repos/sdweber422/echo/assignees{/user}","branches_url":"https://api.github.com/repos/sdweber422/echo/branches{/branch}","tags_url":"https://api.github.com/repos/sdweber422/echo/tags","blobs_url":"https://api.github.com/repos/sdweber422/echo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sdweber422/echo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sdweber422/echo/git/refs{/sha}","trees_url":"https://api.github.com/repos/sdweber422/echo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sdweber422/echo/statuses/{sha}","languages_url":"https://api.github.com/repos/sdweber422/echo/languages","stargazers_url":"https://api.github.com/repos/sdweber422/echo/stargazers","contributors_url":"https://api.github.com/repos/sdweber422/echo/contributors","subscribers_url":"https://api.github.com/repos/sdweber422/echo/subscribers","subscription_url":"https://api.github.com/repos/sdweber422/echo/subscription","commits_url":"https://api.github.com/repos/sdweber422/echo/commits{/sha}","git_commits_url":"https://api.github.com/repos/sdweber422/echo/git/commits{/sha}","comments_url":"https://api.github.com/repos/sdweber422/echo/comments{/number}","issue_comment_url":"https://api.github.com/repos/sdweber422/echo/issues/comments{/number}","contents_url":"https://api.github.com/repos/sdweber422/echo/contents/{+path}","compare_url":"https://api.github.com/repos/sdweber422/echo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sdweber422/echo/merges","archive_url":"https://api.github.com/repos/sdweber422/echo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sdweber422/echo/downloads","issues_url":"https://api.github.com/repos/sdweber422/echo/issues{/number}","pulls_url":"https://api.github.com/repos/sdweber422/echo/pulls{/number}","milestones_url":"https://api.github.com/repos/sdweber422/echo/milestones{/number}","notifications_url":"https://api.github.com/repos/sdweber422/echo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sdweber422/echo/labels{/name}","releases_url":"https://api.github.com/repos/sdweber422/echo/releases{/id}","deployments_url":"https://api.github.com/repos/sdweber422/echo/deployments","created_at":"2017-06-30T18:38:17Z","updated_at":"2017-06-30T18:38:20Z","pushed_at":"2017-07-25T18:19:25Z","git_url":"git://github.com/sdweber422/echo.git","ssh_url":"git@github.com:sdweber422/echo.git","clone_url":"https://github.com/sdweber422/echo.git","svn_url":"https://github.com/sdweber422/echo","homepage":"https://echo.learnersguild.org","size":3521,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"LearnersGuild:master","ref":"master","sha":"9a847924771e3cf60d62ff12b8b33facc3d99ccd","user":{"login":"LearnersGuild","id":14854339,"avatar_url":"https://avatars2.githubusercontent.com/u/14854339?v=4","gravatar_id":"","url":"https://api.github.com/users/LearnersGuild","html_url":"https://github.com/LearnersGuild","followers_url":"https://api.github.com/users/LearnersGuild/followers","following_url":"https://api.github.com/users/LearnersGuild/following{/other_user}","gists_url":"https://api.github.com/users/LearnersGuild/gists{/gist_id}","starred_url":"https://api.github.com/users/LearnersGuild/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LearnersGuild/subscriptions","organizations_url":"https://api.github.com/users/LearnersGuild/orgs","repos_url":"https://api.github.com/users/LearnersGuild/repos","events_url":"https://api.github.com/users/LearnersGuild/events{/privacy}","received_events_url":"https://api.github.com/users/LearnersGuild/received_events","type":"Organization","site_admin":false},"repo":{"id":53369107,"name":"echo","full_name":"LearnersGuild/echo","owner":{"login":"LearnersGuild","id":14854339,"avatar_url":"https://avatars2.githubusercontent.com/u/14854339?v=4","gravatar_id":"","url":"https://api.github.com/users/LearnersGuild","html_url":"https://github.com/LearnersGuild","followers_url":"https://api.github.com/users/LearnersGuild/followers","following_url":"https://api.github.com/users/LearnersGuild/following{/other_user}","gists_url":"https://api.github.com/users/LearnersGuild/gists{/gist_id}","starred_url":"https://api.github.com/users/LearnersGuild/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LearnersGuild/subscriptions","organizations_url":"https://api.github.com/users/LearnersGuild/orgs","repos_url":"https://api.github.com/users/LearnersGuild/repos","events_url":"https://api.github.com/users/LearnersGuild/events{/privacy}","received_events_url":"https://api.github.com/users/LearnersGuild/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LearnersGuild/echo","description":"learning management system","fork":false,"url":"https://api.github.com/repos/LearnersGuild/echo","forks_url":"https://api.github.com/repos/LearnersGuild/echo/forks","keys_url":"https://api.github.com/repos/LearnersGuild/echo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LearnersGuild/echo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LearnersGuild/echo/teams","hooks_url":"https://api.github.com/repos/LearnersGuild/echo/hooks","issue_events_url":"https://api.github.com/repos/LearnersGuild/echo/issues/events{/number}","events_url":"https://api.github.com/repos/LearnersGuild/echo/events","assignees_url":"https://api.github.com/repos/LearnersGuild/echo/assignees{/user}","branches_url":"https://api.github.com/repos/LearnersGuild/echo/branches{/branch}","tags_url":"https://api.github.com/repos/LearnersGuild/echo/tags","blobs_url":"https://api.github.com/repos/LearnersGuild/echo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LearnersGuild/echo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LearnersGuild/echo/git/refs{/sha}","trees_url":"https://api.github.com/repos/LearnersGuild/echo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LearnersGuild/echo/statuses/{sha}","languages_url":"https://api.github.com/repos/LearnersGuild/echo/languages","stargazers_url":"https://api.github.com/repos/LearnersGuild/echo/stargazers","contributors_url":"https://api.github.com/repos/LearnersGuild/echo/contributors","subscribers_url":"https://api.github.com/repos/LearnersGuild/echo/subscribers","subscription_url":"https://api.github.com/repos/LearnersGuild/echo/subscription","commits_url":"https://api.github.com/repos/LearnersGuild/echo/commits{/sha}","git_commits_url":"https://api.github.com/repos/LearnersGuild/echo/git/commits{/sha}","comments_url":"https://api.github.com/repos/LearnersGuild/echo/comments{/number}","issue_comment_url":"https://api.github.com/repos/LearnersGuild/echo/issues/comments{/number}","contents_url":"https://api.github.com/repos/LearnersGuild/echo/contents/{+path}","compare_url":"https://api.github.com/repos/LearnersGuild/echo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LearnersGuild/echo/merges","archive_url":"https://api.github.com/repos/LearnersGuild/echo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LearnersGuild/echo/downloads","issues_url":"https://api.github.com/repos/LearnersGuild/echo/issues{/number}","pulls_url":"https://api.github.com/repos/LearnersGuild/echo/pulls{/number}","milestones_url":"https://api.github.com/repos/LearnersGuild/echo/milestones{/number}","notifications_url":"https://api.github.com/repos/LearnersGuild/echo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LearnersGuild/echo/labels{/name}","releases_url":"https://api.github.com/repos/LearnersGuild/echo/releases{/id}","deployments_url":"https://api.github.com/repos/LearnersGuild/echo/deployments","created_at":"2016-03-08T00:22:36Z","updated_at":"2017-07-18T04:55:42Z","pushed_at":"2017-07-26T15:48:17Z","git_url":"git://github.com/LearnersGuild/echo.git","ssh_url":"git@github.com:LearnersGuild/echo.git","clone_url":"https://github.com/LearnersGuild/echo.git","svn_url":"https://github.com/LearnersGuild/echo","homepage":"","size":3580,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":86,"forks":6,"open_issues":86,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/LearnersGuild/echo/pulls/1052"},"html":{"href":"https://github.com/LearnersGuild/echo/pull/1052"},"issue":{"href":"https://api.github.com/repos/LearnersGuild/echo/issues/1052"},"comments":{"href":"https://api.github.com/repos/LearnersGuild/echo/issues/1052/comments"},"review_comments":{"href":"https://api.github.com/repos/LearnersGuild/echo/pulls/1052/comments"},"review_comment":{"href":"https://api.github.com/repos/LearnersGuild/echo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LearnersGuild/echo/pulls/1052/commits"},"statuses":{"href":"https://api.github.com/repos/LearnersGuild/echo/statuses/80e4d0839cc21df0333feb0c88a0983392eaea60"}}}}
{"actor":{"display_login":"prattsj"}}