{"action":"created","comment":{"url":"https://api.github.com/repos/abhchand/reely/pulls/comments/59123393","id":59123393,"diff_hunk":"@@ -0,0 +1,64 @@\n+class AuthenticateUser::Native\n+  include Interactor\n+\n+  def call\n+    @params = context.params\n+\n+    case\n+    when missing_email?\n+      handle_missing_email\n+    when missing_password?\n+      handle_missing_password\n+    when wrong_email?\n+      handle_wrong_email\n+    when wrong_password?\n+      handle_wrong_password\n+    end\n+  end\n+\n+  private\n+\n+  def i18n_scope\n+    \"sessions.log_in.validation\"\n+  end\n+\n+  def missing_email?\n+    @params[:email].blank?\n+  end\n+\n+  def handle_missing_email\n+    context.fail!(error_message: I18n.t(\".no_email\", scope: i18n_scope))\n+  end\n+\n+  def missing_password?\n+    @params[:password].blank?\n+  end\n+\n+  def handle_missing_password\n+    context.fail!(error_message: I18n.t(\".no_password\", scope: i18n_scope))\n+  end\n+\n+  def wrong_email?\n+    search_params = {\n+      email: @params[:email],\n+      identities: { provider: Identity::NATIVE, email: @params[:email] }\n+    }\n+    @search_results = User.joins(:identities).where(search_params)\n+    @search_results.empty?\n+  end\n+\n+  def handle_wrong_email\n+    context.fail!(error_message: I18n.t(\".wrong_email\", scope: i18n_scope))\n+  end\n+\n+  def wrong_password?\n+    context.user = @search_results.select do |result|","path":"app/services/authenticate_user/native.rb","position":55,"original_position":55,"commit_id":"339fa4c2402ba73eb4a95c36691f6a3e4210d3fb","original_commit_id":"339fa4c2402ba73eb4a95c36691f6a3e4210d3fb","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Use `find` instead of `select.first`.","created_at":"2016-04-09T23:12:43Z","updated_at":"2016-04-09T23:12:43Z","html_url":"https://github.com/abhchand/reely/pull/4#discussion_r59123393","pull_request_url":"https://api.github.com/repos/abhchand/reely/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/abhchand/reely/pulls/comments/59123393"},"html":{"href":"https://github.com/abhchand/reely/pull/4#discussion_r59123393"},"pull_request":{"href":"https://api.github.com/repos/abhchand/reely/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/abhchand/reely/pulls/4","id":65895458,"html_url":"https://github.com/abhchand/reely/pull/4","diff_url":"https://github.com/abhchand/reely/pull/4.diff","patch_url":"https://github.com/abhchand/reely/pull/4.patch","issue_url":"https://api.github.com/repos/abhchand/reely/issues/4","number":4,"state":"open","locked":false,"title":"Authentication","user":{"login":"abhchand","id":13787645,"avatar_url":"https://avatars.githubusercontent.com/u/13787645?v=3","gravatar_id":"","url":"https://api.github.com/users/abhchand","html_url":"https://github.com/abhchand","followers_url":"https://api.github.com/users/abhchand/followers","following_url":"https://api.github.com/users/abhchand/following{/other_user}","gists_url":"https://api.github.com/users/abhchand/gists{/gist_id}","starred_url":"https://api.github.com/users/abhchand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhchand/subscriptions","organizations_url":"https://api.github.com/users/abhchand/orgs","repos_url":"https://api.github.com/users/abhchand/repos","events_url":"https://api.github.com/users/abhchand/events{/privacy}","received_events_url":"https://api.github.com/users/abhchand/received_events","type":"User","site_admin":false},"body":"Adding authentication","created_at":"2016-04-09T23:12:29Z","updated_at":"2016-04-09T23:12:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e049176d79091138816a90be46beeebc79eee5c1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/abhchand/reely/pulls/4/commits","review_comments_url":"https://api.github.com/repos/abhchand/reely/pulls/4/comments","review_comment_url":"https://api.github.com/repos/abhchand/reely/pulls/comments{/number}","comments_url":"https://api.github.com/repos/abhchand/reely/issues/4/comments","statuses_url":"https://api.github.com/repos/abhchand/reely/statuses/339fa4c2402ba73eb4a95c36691f6a3e4210d3fb","head":{"label":"abhchand:authentication","ref":"authentication","sha":"339fa4c2402ba73eb4a95c36691f6a3e4210d3fb","user":{"login":"abhchand","id":13787645,"avatar_url":"https://avatars.githubusercontent.com/u/13787645?v=3","gravatar_id":"","url":"https://api.github.com/users/abhchand","html_url":"https://github.com/abhchand","followers_url":"https://api.github.com/users/abhchand/followers","following_url":"https://api.github.com/users/abhchand/following{/other_user}","gists_url":"https://api.github.com/users/abhchand/gists{/gist_id}","starred_url":"https://api.github.com/users/abhchand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhchand/subscriptions","organizations_url":"https://api.github.com/users/abhchand/orgs","repos_url":"https://api.github.com/users/abhchand/repos","events_url":"https://api.github.com/users/abhchand/events{/privacy}","received_events_url":"https://api.github.com/users/abhchand/received_events","type":"User","site_admin":false},"repo":{"id":49841693,"name":"reely","full_name":"abhchand/reely","owner":{"login":"abhchand","id":13787645,"avatar_url":"https://avatars.githubusercontent.com/u/13787645?v=3","gravatar_id":"","url":"https://api.github.com/users/abhchand","html_url":"https://github.com/abhchand","followers_url":"https://api.github.com/users/abhchand/followers","following_url":"https://api.github.com/users/abhchand/following{/other_user}","gists_url":"https://api.github.com/users/abhchand/gists{/gist_id}","starred_url":"https://api.github.com/users/abhchand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhchand/subscriptions","organizations_url":"https://api.github.com/users/abhchand/orgs","repos_url":"https://api.github.com/users/abhchand/repos","events_url":"https://api.github.com/users/abhchand/events{/privacy}","received_events_url":"https://api.github.com/users/abhchand/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abhchand/reely","description":"reely.co","fork":false,"url":"https://api.github.com/repos/abhchand/reely","forks_url":"https://api.github.com/repos/abhchand/reely/forks","keys_url":"https://api.github.com/repos/abhchand/reely/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abhchand/reely/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abhchand/reely/teams","hooks_url":"https://api.github.com/repos/abhchand/reely/hooks","issue_events_url":"https://api.github.com/repos/abhchand/reely/issues/events{/number}","events_url":"https://api.github.com/repos/abhchand/reely/events","assignees_url":"https://api.github.com/repos/abhchand/reely/assignees{/user}","branches_url":"https://api.github.com/repos/abhchand/reely/branches{/branch}","tags_url":"https://api.github.com/repos/abhchand/reely/tags","blobs_url":"https://api.github.com/repos/abhchand/reely/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abhchand/reely/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abhchand/reely/git/refs{/sha}","trees_url":"https://api.github.com/repos/abhchand/reely/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abhchand/reely/statuses/{sha}","languages_url":"https://api.github.com/repos/abhchand/reely/languages","stargazers_url":"https://api.github.com/repos/abhchand/reely/stargazers","contributors_url":"https://api.github.com/repos/abhchand/reely/contributors","subscribers_url":"https://api.github.com/repos/abhchand/reely/subscribers","subscription_url":"https://api.github.com/repos/abhchand/reely/subscription","commits_url":"https://api.github.com/repos/abhchand/reely/commits{/sha}","git_commits_url":"https://api.github.com/repos/abhchand/reely/git/commits{/sha}","comments_url":"https://api.github.com/repos/abhchand/reely/comments{/number}","issue_comment_url":"https://api.github.com/repos/abhchand/reely/issues/comments{/number}","contents_url":"https://api.github.com/repos/abhchand/reely/contents/{+path}","compare_url":"https://api.github.com/repos/abhchand/reely/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abhchand/reely/merges","archive_url":"https://api.github.com/repos/abhchand/reely/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abhchand/reely/downloads","issues_url":"https://api.github.com/repos/abhchand/reely/issues{/number}","pulls_url":"https://api.github.com/repos/abhchand/reely/pulls{/number}","milestones_url":"https://api.github.com/repos/abhchand/reely/milestones{/number}","notifications_url":"https://api.github.com/repos/abhchand/reely/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abhchand/reely/labels{/name}","releases_url":"https://api.github.com/repos/abhchand/reely/releases{/id}","deployments_url":"https://api.github.com/repos/abhchand/reely/deployments","created_at":"2016-01-18T00:02:59Z","updated_at":"2016-01-24T10:04:36Z","pushed_at":"2016-04-09T23:12:29Z","git_url":"git://github.com/abhchand/reely.git","ssh_url":"git@github.com:abhchand/reely.git","clone_url":"https://github.com/abhchand/reely.git","svn_url":"https://github.com/abhchand/reely","homepage":null,"size":10804,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"abhchand:master","ref":"master","sha":"5c8349e0827b7b0be7aa89d0e9cc9f548103b1c0","user":{"login":"abhchand","id":13787645,"avatar_url":"https://avatars.githubusercontent.com/u/13787645?v=3","gravatar_id":"","url":"https://api.github.com/users/abhchand","html_url":"https://github.com/abhchand","followers_url":"https://api.github.com/users/abhchand/followers","following_url":"https://api.github.com/users/abhchand/following{/other_user}","gists_url":"https://api.github.com/users/abhchand/gists{/gist_id}","starred_url":"https://api.github.com/users/abhchand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhchand/subscriptions","organizations_url":"https://api.github.com/users/abhchand/orgs","repos_url":"https://api.github.com/users/abhchand/repos","events_url":"https://api.github.com/users/abhchand/events{/privacy}","received_events_url":"https://api.github.com/users/abhchand/received_events","type":"User","site_admin":false},"repo":{"id":49841693,"name":"reely","full_name":"abhchand/reely","owner":{"login":"abhchand","id":13787645,"avatar_url":"https://avatars.githubusercontent.com/u/13787645?v=3","gravatar_id":"","url":"https://api.github.com/users/abhchand","html_url":"https://github.com/abhchand","followers_url":"https://api.github.com/users/abhchand/followers","following_url":"https://api.github.com/users/abhchand/following{/other_user}","gists_url":"https://api.github.com/users/abhchand/gists{/gist_id}","starred_url":"https://api.github.com/users/abhchand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhchand/subscriptions","organizations_url":"https://api.github.com/users/abhchand/orgs","repos_url":"https://api.github.com/users/abhchand/repos","events_url":"https://api.github.com/users/abhchand/events{/privacy}","received_events_url":"https://api.github.com/users/abhchand/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abhchand/reely","description":"reely.co","fork":false,"url":"https://api.github.com/repos/abhchand/reely","forks_url":"https://api.github.com/repos/abhchand/reely/forks","keys_url":"https://api.github.com/repos/abhchand/reely/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abhchand/reely/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abhchand/reely/teams","hooks_url":"https://api.github.com/repos/abhchand/reely/hooks","issue_events_url":"https://api.github.com/repos/abhchand/reely/issues/events{/number}","events_url":"https://api.github.com/repos/abhchand/reely/events","assignees_url":"https://api.github.com/repos/abhchand/reely/assignees{/user}","branches_url":"https://api.github.com/repos/abhchand/reely/branches{/branch}","tags_url":"https://api.github.com/repos/abhchand/reely/tags","blobs_url":"https://api.github.com/repos/abhchand/reely/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abhchand/reely/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abhchand/reely/git/refs{/sha}","trees_url":"https://api.github.com/repos/abhchand/reely/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abhchand/reely/statuses/{sha}","languages_url":"https://api.github.com/repos/abhchand/reely/languages","stargazers_url":"https://api.github.com/repos/abhchand/reely/stargazers","contributors_url":"https://api.github.com/repos/abhchand/reely/contributors","subscribers_url":"https://api.github.com/repos/abhchand/reely/subscribers","subscription_url":"https://api.github.com/repos/abhchand/reely/subscription","commits_url":"https://api.github.com/repos/abhchand/reely/commits{/sha}","git_commits_url":"https://api.github.com/repos/abhchand/reely/git/commits{/sha}","comments_url":"https://api.github.com/repos/abhchand/reely/comments{/number}","issue_comment_url":"https://api.github.com/repos/abhchand/reely/issues/comments{/number}","contents_url":"https://api.github.com/repos/abhchand/reely/contents/{+path}","compare_url":"https://api.github.com/repos/abhchand/reely/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abhchand/reely/merges","archive_url":"https://api.github.com/repos/abhchand/reely/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abhchand/reely/downloads","issues_url":"https://api.github.com/repos/abhchand/reely/issues{/number}","pulls_url":"https://api.github.com/repos/abhchand/reely/pulls{/number}","milestones_url":"https://api.github.com/repos/abhchand/reely/milestones{/number}","notifications_url":"https://api.github.com/repos/abhchand/reely/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abhchand/reely/labels{/name}","releases_url":"https://api.github.com/repos/abhchand/reely/releases{/id}","deployments_url":"https://api.github.com/repos/abhchand/reely/deployments","created_at":"2016-01-18T00:02:59Z","updated_at":"2016-01-24T10:04:36Z","pushed_at":"2016-04-09T23:12:29Z","git_url":"git://github.com/abhchand/reely.git","ssh_url":"git@github.com:abhchand/reely.git","clone_url":"https://github.com/abhchand/reely.git","svn_url":"https://github.com/abhchand/reely","homepage":null,"size":10804,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/abhchand/reely/pulls/4"},"html":{"href":"https://github.com/abhchand/reely/pull/4"},"issue":{"href":"https://api.github.com/repos/abhchand/reely/issues/4"},"comments":{"href":"https://api.github.com/repos/abhchand/reely/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/abhchand/reely/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/abhchand/reely/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/abhchand/reely/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/abhchand/reely/statuses/339fa4c2402ba73eb4a95c36691f6a3e4210d3fb"}}}}