{"action":"created","comment":{"url":"https://api.github.com/repos/cantino/huginn/pulls/comments/77012900","id":77012900,"diff_hunk":"@@ -83,6 +83,26 @@ def activate\n     end\n   end\n \n+  # allow an admin to sign-in as any other user\n+\n+  def switch_to_user\n+    if current_user != @user\n+      sign_in(:user, @user, { bypass: true })\n+      session[:original_admin_user_id] = current_user.id\n+    end\n+    redirect_to agents_path\n+  end\n+\n+  def switch_back\n+    if session[:original_admin_user_id].present?\n+      sign_in(:user, User.find(session[:original_admin_user_id]), { bypass: true })\n+      session.delete(:original_admin_user_id)\n+    else\n+      redirect_to(root_path, alert: 'Admin access required to view that page.') and return","path":"app/controllers/admin/users_controller.rb","position":29,"original_position":29,"commit_id":"5eac0434e06a4a1e1dd390b021fa3127a420e55d","original_commit_id":"5eac0434e06a4a1e1dd390b021fa3127a420e55d","user":{"login":"cantino","id":83835,"avatar_url":"https://avatars.githubusercontent.com/u/83835?v=3","gravatar_id":"","url":"https://api.github.com/users/cantino","html_url":"https://github.com/cantino","followers_url":"https://api.github.com/users/cantino/followers","following_url":"https://api.github.com/users/cantino/following{/other_user}","gists_url":"https://api.github.com/users/cantino/gists{/gist_id}","starred_url":"https://api.github.com/users/cantino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cantino/subscriptions","organizations_url":"https://api.github.com/users/cantino/orgs","repos_url":"https://api.github.com/users/cantino/repos","events_url":"https://api.github.com/users/cantino/events{/privacy}","received_events_url":"https://api.github.com/users/cantino/received_events","type":"User","site_admin":false},"body":"Maybe `'You must be acting as a different user to view that page'`?","created_at":"2016-08-31T15:43:54Z","updated_at":"2016-08-31T15:43:54Z","html_url":"https://github.com/cantino/huginn/pull/1659#discussion_r77012900","pull_request_url":"https://api.github.com/repos/cantino/huginn/pulls/1659","_links":{"self":{"href":"https://api.github.com/repos/cantino/huginn/pulls/comments/77012900"},"html":{"href":"https://github.com/cantino/huginn/pull/1659#discussion_r77012900"},"pull_request":{"href":"https://api.github.com/repos/cantino/huginn/pulls/1659"}}},"pull_request":{"url":"https://api.github.com/repos/cantino/huginn/pulls/1659","id":83371217,"html_url":"https://github.com/cantino/huginn/pull/1659","diff_url":"https://github.com/cantino/huginn/pull/1659.diff","patch_url":"https://github.com/cantino/huginn/pull/1659.patch","issue_url":"https://api.github.com/repos/cantino/huginn/issues/1659","number":1659,"state":"open","locked":false,"title":"Admin \"become\" method","user":{"login":"albertsun","id":382862,"avatar_url":"https://avatars.githubusercontent.com/u/382862?v=3","gravatar_id":"","url":"https://api.github.com/users/albertsun","html_url":"https://github.com/albertsun","followers_url":"https://api.github.com/users/albertsun/followers","following_url":"https://api.github.com/users/albertsun/following{/other_user}","gists_url":"https://api.github.com/users/albertsun/gists{/gist_id}","starred_url":"https://api.github.com/users/albertsun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertsun/subscriptions","organizations_url":"https://api.github.com/users/albertsun/orgs","repos_url":"https://api.github.com/users/albertsun/repos","events_url":"https://api.github.com/users/albertsun/events{/privacy}","received_events_url":"https://api.github.com/users/albertsun/received_events","type":"User","site_admin":false},"body":"One part of https://github.com/cantino/huginn/pull/1593\r\n\r\nAdds the following routes to allow an admin user to temporarily become another user and then switch back. And some UI for doing that.\r\n\r\n```\r\nswitch_user_admin_user GET                 /admin/users/:id/switch_user(.:format)                   admin/users#switch_user\r\nswitch_back_admin_users GET                 /admin/users/switch_back(.:format)                       admin/users#switch_back\r\n```\r\n\r\n","created_at":"2016-08-31T00:40:21Z","updated_at":"2016-08-31T15:43:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"de105ffcabb8a88a7200ca02d26e3d9a08b2e782","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cantino/huginn/pulls/1659/commits","review_comments_url":"https://api.github.com/repos/cantino/huginn/pulls/1659/comments","review_comment_url":"https://api.github.com/repos/cantino/huginn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cantino/huginn/issues/1659/comments","statuses_url":"https://api.github.com/repos/cantino/huginn/statuses/5eac0434e06a4a1e1dd390b021fa3127a420e55d","head":{"label":"albertsun:feature/admin-switch-user","ref":"feature/admin-switch-user","sha":"5eac0434e06a4a1e1dd390b021fa3127a420e55d","user":{"login":"albertsun","id":382862,"avatar_url":"https://avatars.githubusercontent.com/u/382862?v=3","gravatar_id":"","url":"https://api.github.com/users/albertsun","html_url":"https://github.com/albertsun","followers_url":"https://api.github.com/users/albertsun/followers","following_url":"https://api.github.com/users/albertsun/following{/other_user}","gists_url":"https://api.github.com/users/albertsun/gists{/gist_id}","starred_url":"https://api.github.com/users/albertsun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertsun/subscriptions","organizations_url":"https://api.github.com/users/albertsun/orgs","repos_url":"https://api.github.com/users/albertsun/repos","events_url":"https://api.github.com/users/albertsun/events{/privacy}","received_events_url":"https://api.github.com/users/albertsun/received_events","type":"User","site_admin":false},"repo":{"id":9251577,"name":"huginn","full_name":"albertsun/huginn","owner":{"login":"albertsun","id":382862,"avatar_url":"https://avatars.githubusercontent.com/u/382862?v=3","gravatar_id":"","url":"https://api.github.com/users/albertsun","html_url":"https://github.com/albertsun","followers_url":"https://api.github.com/users/albertsun/followers","following_url":"https://api.github.com/users/albertsun/following{/other_user}","gists_url":"https://api.github.com/users/albertsun/gists{/gist_id}","starred_url":"https://api.github.com/users/albertsun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertsun/subscriptions","organizations_url":"https://api.github.com/users/albertsun/orgs","repos_url":"https://api.github.com/users/albertsun/repos","events_url":"https://api.github.com/users/albertsun/events{/privacy}","received_events_url":"https://api.github.com/users/albertsun/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/albertsun/huginn","description":"Build agents that monitor and act on your behalf.  Your agents are standing by!","fork":true,"url":"https://api.github.com/repos/albertsun/huginn","forks_url":"https://api.github.com/repos/albertsun/huginn/forks","keys_url":"https://api.github.com/repos/albertsun/huginn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/albertsun/huginn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/albertsun/huginn/teams","hooks_url":"https://api.github.com/repos/albertsun/huginn/hooks","issue_events_url":"https://api.github.com/repos/albertsun/huginn/issues/events{/number}","events_url":"https://api.github.com/repos/albertsun/huginn/events","assignees_url":"https://api.github.com/repos/albertsun/huginn/assignees{/user}","branches_url":"https://api.github.com/repos/albertsun/huginn/branches{/branch}","tags_url":"https://api.github.com/repos/albertsun/huginn/tags","blobs_url":"https://api.github.com/repos/albertsun/huginn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/albertsun/huginn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/albertsun/huginn/git/refs{/sha}","trees_url":"https://api.github.com/repos/albertsun/huginn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/albertsun/huginn/statuses/{sha}","languages_url":"https://api.github.com/repos/albertsun/huginn/languages","stargazers_url":"https://api.github.com/repos/albertsun/huginn/stargazers","contributors_url":"https://api.github.com/repos/albertsun/huginn/contributors","subscribers_url":"https://api.github.com/repos/albertsun/huginn/subscribers","subscription_url":"https://api.github.com/repos/albertsun/huginn/subscription","commits_url":"https://api.github.com/repos/albertsun/huginn/commits{/sha}","git_commits_url":"https://api.github.com/repos/albertsun/huginn/git/commits{/sha}","comments_url":"https://api.github.com/repos/albertsun/huginn/comments{/number}","issue_comment_url":"https://api.github.com/repos/albertsun/huginn/issues/comments{/number}","contents_url":"https://api.github.com/repos/albertsun/huginn/contents/{+path}","compare_url":"https://api.github.com/repos/albertsun/huginn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/albertsun/huginn/merges","archive_url":"https://api.github.com/repos/albertsun/huginn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/albertsun/huginn/downloads","issues_url":"https://api.github.com/repos/albertsun/huginn/issues{/number}","pulls_url":"https://api.github.com/repos/albertsun/huginn/pulls{/number}","milestones_url":"https://api.github.com/repos/albertsun/huginn/milestones{/number}","notifications_url":"https://api.github.com/repos/albertsun/huginn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/albertsun/huginn/labels{/name}","releases_url":"https://api.github.com/repos/albertsun/huginn/releases{/id}","deployments_url":"https://api.github.com/repos/albertsun/huginn/deployments","created_at":"2013-04-05T22:01:53Z","updated_at":"2015-03-02T14:24:49Z","pushed_at":"2016-08-31T14:57:34Z","git_url":"git://github.com/albertsun/huginn.git","ssh_url":"git@github.com:albertsun/huginn.git","clone_url":"https://github.com/albertsun/huginn.git","svn_url":"https://github.com/albertsun/huginn","homepage":null,"size":6520,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"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":"cantino:master","ref":"master","sha":"a6fe9743f65dee0123a6c080236717b626ea6cec","user":{"login":"cantino","id":83835,"avatar_url":"https://avatars.githubusercontent.com/u/83835?v=3","gravatar_id":"","url":"https://api.github.com/users/cantino","html_url":"https://github.com/cantino","followers_url":"https://api.github.com/users/cantino/followers","following_url":"https://api.github.com/users/cantino/following{/other_user}","gists_url":"https://api.github.com/users/cantino/gists{/gist_id}","starred_url":"https://api.github.com/users/cantino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cantino/subscriptions","organizations_url":"https://api.github.com/users/cantino/orgs","repos_url":"https://api.github.com/users/cantino/repos","events_url":"https://api.github.com/users/cantino/events{/privacy}","received_events_url":"https://api.github.com/users/cantino/received_events","type":"User","site_admin":false},"repo":{"id":8681349,"name":"huginn","full_name":"cantino/huginn","owner":{"login":"cantino","id":83835,"avatar_url":"https://avatars.githubusercontent.com/u/83835?v=3","gravatar_id":"","url":"https://api.github.com/users/cantino","html_url":"https://github.com/cantino","followers_url":"https://api.github.com/users/cantino/followers","following_url":"https://api.github.com/users/cantino/following{/other_user}","gists_url":"https://api.github.com/users/cantino/gists{/gist_id}","starred_url":"https://api.github.com/users/cantino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cantino/subscriptions","organizations_url":"https://api.github.com/users/cantino/orgs","repos_url":"https://api.github.com/users/cantino/repos","events_url":"https://api.github.com/users/cantino/events{/privacy}","received_events_url":"https://api.github.com/users/cantino/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cantino/huginn","description":"Build agents that monitor and act on your behalf.  Your agents are standing by!","fork":false,"url":"https://api.github.com/repos/cantino/huginn","forks_url":"https://api.github.com/repos/cantino/huginn/forks","keys_url":"https://api.github.com/repos/cantino/huginn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cantino/huginn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cantino/huginn/teams","hooks_url":"https://api.github.com/repos/cantino/huginn/hooks","issue_events_url":"https://api.github.com/repos/cantino/huginn/issues/events{/number}","events_url":"https://api.github.com/repos/cantino/huginn/events","assignees_url":"https://api.github.com/repos/cantino/huginn/assignees{/user}","branches_url":"https://api.github.com/repos/cantino/huginn/branches{/branch}","tags_url":"https://api.github.com/repos/cantino/huginn/tags","blobs_url":"https://api.github.com/repos/cantino/huginn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cantino/huginn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cantino/huginn/git/refs{/sha}","trees_url":"https://api.github.com/repos/cantino/huginn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cantino/huginn/statuses/{sha}","languages_url":"https://api.github.com/repos/cantino/huginn/languages","stargazers_url":"https://api.github.com/repos/cantino/huginn/stargazers","contributors_url":"https://api.github.com/repos/cantino/huginn/contributors","subscribers_url":"https://api.github.com/repos/cantino/huginn/subscribers","subscription_url":"https://api.github.com/repos/cantino/huginn/subscription","commits_url":"https://api.github.com/repos/cantino/huginn/commits{/sha}","git_commits_url":"https://api.github.com/repos/cantino/huginn/git/commits{/sha}","comments_url":"https://api.github.com/repos/cantino/huginn/comments{/number}","issue_comment_url":"https://api.github.com/repos/cantino/huginn/issues/comments{/number}","contents_url":"https://api.github.com/repos/cantino/huginn/contents/{+path}","compare_url":"https://api.github.com/repos/cantino/huginn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cantino/huginn/merges","archive_url":"https://api.github.com/repos/cantino/huginn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cantino/huginn/downloads","issues_url":"https://api.github.com/repos/cantino/huginn/issues{/number}","pulls_url":"https://api.github.com/repos/cantino/huginn/pulls{/number}","milestones_url":"https://api.github.com/repos/cantino/huginn/milestones{/number}","notifications_url":"https://api.github.com/repos/cantino/huginn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cantino/huginn/labels{/name}","releases_url":"https://api.github.com/repos/cantino/huginn/releases{/id}","deployments_url":"https://api.github.com/repos/cantino/huginn/deployments","created_at":"2013-03-10T06:00:31Z","updated_at":"2016-08-31T12:45:28Z","pushed_at":"2016-08-31T15:37:52Z","git_url":"git://github.com/cantino/huginn.git","ssh_url":"git@github.com:cantino/huginn.git","clone_url":"https://github.com/cantino/huginn.git","svn_url":"https://github.com/cantino/huginn","homepage":null,"size":9333,"stargazers_count":14670,"watchers_count":14670,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1562,"mirror_url":null,"open_issues_count":233,"forks":1562,"open_issues":233,"watchers":14670,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cantino/huginn/pulls/1659"},"html":{"href":"https://github.com/cantino/huginn/pull/1659"},"issue":{"href":"https://api.github.com/repos/cantino/huginn/issues/1659"},"comments":{"href":"https://api.github.com/repos/cantino/huginn/issues/1659/comments"},"review_comments":{"href":"https://api.github.com/repos/cantino/huginn/pulls/1659/comments"},"review_comment":{"href":"https://api.github.com/repos/cantino/huginn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cantino/huginn/pulls/1659/commits"},"statuses":{"href":"https://api.github.com/repos/cantino/huginn/statuses/5eac0434e06a4a1e1dd390b021fa3127a420e55d"}}}}
{"actor":{"display_login":"cantino"}}