{"action":"created","comment":{"url":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/comments/174719805","pull_request_review_id":104114638,"id":174719805,"diff_hunk":"@@ -6,31 +6,37 @@ def initialize(auth)\n   end\n \n   def get\n-    user\n+    check_auth\n+    @user\n   end\n \n   private\n \n   delegate :provider, :uid, :info, to: :auth\n   delegate :email, to: :info\n \n-  def user\n-    @_user ||= find_user || create_user\n+  def find_authorization(user)\n+    user.authorizations.where(provider: provider, uid: uid).first\n   end\n \n-  def find_user\n-    User.where(provider: provider, uid: uid, email: email).first\n+  def create_authorization(user)\n+    user.authorizations.create(provider: provider, uid: uid)\n+  end\n+\n+  def initiate_user\n+    @user = User.where(email: email).first || create_user\n+  end\n+\n+  def check_auth\n+    initiate_user\n+    create_authorization(@user) if find_authorization(@user).blank?","path":"app/services/users/omniauth.rb","position":32,"original_position":32,"commit_id":"fd86511ed538dfa57a8cb26f044eca6913f8e00a","original_commit_id":"fd86511ed538dfa57a8cb26f044eca6913f8e00a","user":{"login":"AleksSenkou","id":3635774,"avatar_url":"https://avatars2.githubusercontent.com/u/3635774?v=4","gravatar_id":"","url":"https://api.github.com/users/AleksSenkou","html_url":"https://github.com/AleksSenkou","followers_url":"https://api.github.com/users/AleksSenkou/followers","following_url":"https://api.github.com/users/AleksSenkou/following{/other_user}","gists_url":"https://api.github.com/users/AleksSenkou/gists{/gist_id}","starred_url":"https://api.github.com/users/AleksSenkou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AleksSenkou/subscriptions","organizations_url":"https://api.github.com/users/AleksSenkou/orgs","repos_url":"https://api.github.com/users/AleksSenkou/repos","events_url":"https://api.github.com/users/AleksSenkou/events{/privacy}","received_events_url":"https://api.github.com/users/AleksSenkou/received_events","type":"User","site_admin":false},"body":"@sinpai [find_or_create_by](https://apidock.com/rails/v4.0.2/ActiveRecord/Relation/find_or_create_by) can be used","created_at":"2018-03-15T09:25:58Z","updated_at":"2018-03-15T09:27:04Z","html_url":"https://github.com/sinpai/datarockets-finance-app/pull/11#discussion_r174719805","pull_request_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/11","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/comments/174719805"},"html":{"href":"https://github.com/sinpai/datarockets-finance-app/pull/11#discussion_r174719805"},"pull_request":{"href":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/11","id":174906022,"html_url":"https://github.com/sinpai/datarockets-finance-app/pull/11","diff_url":"https://github.com/sinpai/datarockets-finance-app/pull/11.diff","patch_url":"https://github.com/sinpai/datarockets-finance-app/pull/11.patch","issue_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/issues/11","number":11,"state":"open","locked":false,"title":"Fix - Multiply oauth accounts","user":{"login":"sinpai","id":4716237,"avatar_url":"https://avatars3.githubusercontent.com/u/4716237?v=4","gravatar_id":"","url":"https://api.github.com/users/sinpai","html_url":"https://github.com/sinpai","followers_url":"https://api.github.com/users/sinpai/followers","following_url":"https://api.github.com/users/sinpai/following{/other_user}","gists_url":"https://api.github.com/users/sinpai/gists{/gist_id}","starred_url":"https://api.github.com/users/sinpai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinpai/subscriptions","organizations_url":"https://api.github.com/users/sinpai/orgs","repos_url":"https://api.github.com/users/sinpai/repos","events_url":"https://api.github.com/users/sinpai/events{/privacy}","received_events_url":"https://api.github.com/users/sinpai/received_events","type":"User","site_admin":false},"body":"* Added fix to handle multiply oauth connections to user\r\n* New model Authorization has been created\r\n* Omniauth services has been changed a lot","created_at":"2018-03-14T10:08:03Z","updated_at":"2018-03-15T09:27:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7252c9933102b26662cc6eaed963a418f1de11e5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":842512042,"url":"https://api.github.com/repos/sinpai/datarockets-finance-app/labels/bug","name":"bug","color":"d73a4a","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/11/commits","review_comments_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/11/comments","review_comment_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/issues/11/comments","statuses_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/statuses/fd86511ed538dfa57a8cb26f044eca6913f8e00a","head":{"label":"sinpai:fix/multiply-oauth-accounts","ref":"fix/multiply-oauth-accounts","sha":"fd86511ed538dfa57a8cb26f044eca6913f8e00a","user":{"login":"sinpai","id":4716237,"avatar_url":"https://avatars3.githubusercontent.com/u/4716237?v=4","gravatar_id":"","url":"https://api.github.com/users/sinpai","html_url":"https://github.com/sinpai","followers_url":"https://api.github.com/users/sinpai/followers","following_url":"https://api.github.com/users/sinpai/following{/other_user}","gists_url":"https://api.github.com/users/sinpai/gists{/gist_id}","starred_url":"https://api.github.com/users/sinpai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinpai/subscriptions","organizations_url":"https://api.github.com/users/sinpai/orgs","repos_url":"https://api.github.com/users/sinpai/repos","events_url":"https://api.github.com/users/sinpai/events{/privacy}","received_events_url":"https://api.github.com/users/sinpai/received_events","type":"User","site_admin":false},"repo":{"id":122171597,"name":"datarockets-finance-app","full_name":"sinpai/datarockets-finance-app","owner":{"login":"sinpai","id":4716237,"avatar_url":"https://avatars3.githubusercontent.com/u/4716237?v=4","gravatar_id":"","url":"https://api.github.com/users/sinpai","html_url":"https://github.com/sinpai","followers_url":"https://api.github.com/users/sinpai/followers","following_url":"https://api.github.com/users/sinpai/following{/other_user}","gists_url":"https://api.github.com/users/sinpai/gists{/gist_id}","starred_url":"https://api.github.com/users/sinpai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinpai/subscriptions","organizations_url":"https://api.github.com/users/sinpai/orgs","repos_url":"https://api.github.com/users/sinpai/repos","events_url":"https://api.github.com/users/sinpai/events{/privacy}","received_events_url":"https://api.github.com/users/sinpai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sinpai/datarockets-finance-app","description":null,"fork":false,"url":"https://api.github.com/repos/sinpai/datarockets-finance-app","forks_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/forks","keys_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/teams","hooks_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/hooks","issue_events_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/issues/events{/number}","events_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/events","assignees_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/assignees{/user}","branches_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/branches{/branch}","tags_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/tags","blobs_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/statuses/{sha}","languages_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/languages","stargazers_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/stargazers","contributors_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/contributors","subscribers_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/subscribers","subscription_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/subscription","commits_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/contents/{+path}","compare_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/merges","archive_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/downloads","issues_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/issues{/number}","pulls_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls{/number}","milestones_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/milestones{/number}","notifications_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/labels{/name}","releases_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/releases{/id}","deployments_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/deployments","created_at":"2018-02-20T08:20:04Z","updated_at":"2018-03-14T12:34:41Z","pushed_at":"2018-03-15T09:13:19Z","git_url":"git://github.com/sinpai/datarockets-finance-app.git","ssh_url":"git@github.com:sinpai/datarockets-finance-app.git","clone_url":"https://github.com/sinpai/datarockets-finance-app.git","svn_url":"https://github.com/sinpai/datarockets-finance-app","homepage":null,"size":320,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"sinpai:module-3/modal-window-and-crud-actions","ref":"module-3/modal-window-and-crud-actions","sha":"66ea630849ae0617cd8c0ddb065fe687388dff56","user":{"login":"sinpai","id":4716237,"avatar_url":"https://avatars3.githubusercontent.com/u/4716237?v=4","gravatar_id":"","url":"https://api.github.com/users/sinpai","html_url":"https://github.com/sinpai","followers_url":"https://api.github.com/users/sinpai/followers","following_url":"https://api.github.com/users/sinpai/following{/other_user}","gists_url":"https://api.github.com/users/sinpai/gists{/gist_id}","starred_url":"https://api.github.com/users/sinpai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinpai/subscriptions","organizations_url":"https://api.github.com/users/sinpai/orgs","repos_url":"https://api.github.com/users/sinpai/repos","events_url":"https://api.github.com/users/sinpai/events{/privacy}","received_events_url":"https://api.github.com/users/sinpai/received_events","type":"User","site_admin":false},"repo":{"id":122171597,"name":"datarockets-finance-app","full_name":"sinpai/datarockets-finance-app","owner":{"login":"sinpai","id":4716237,"avatar_url":"https://avatars3.githubusercontent.com/u/4716237?v=4","gravatar_id":"","url":"https://api.github.com/users/sinpai","html_url":"https://github.com/sinpai","followers_url":"https://api.github.com/users/sinpai/followers","following_url":"https://api.github.com/users/sinpai/following{/other_user}","gists_url":"https://api.github.com/users/sinpai/gists{/gist_id}","starred_url":"https://api.github.com/users/sinpai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinpai/subscriptions","organizations_url":"https://api.github.com/users/sinpai/orgs","repos_url":"https://api.github.com/users/sinpai/repos","events_url":"https://api.github.com/users/sinpai/events{/privacy}","received_events_url":"https://api.github.com/users/sinpai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sinpai/datarockets-finance-app","description":null,"fork":false,"url":"https://api.github.com/repos/sinpai/datarockets-finance-app","forks_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/forks","keys_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/teams","hooks_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/hooks","issue_events_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/issues/events{/number}","events_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/events","assignees_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/assignees{/user}","branches_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/branches{/branch}","tags_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/tags","blobs_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/statuses/{sha}","languages_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/languages","stargazers_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/stargazers","contributors_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/contributors","subscribers_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/subscribers","subscription_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/subscription","commits_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/contents/{+path}","compare_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/merges","archive_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/downloads","issues_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/issues{/number}","pulls_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls{/number}","milestones_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/milestones{/number}","notifications_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/labels{/name}","releases_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/releases{/id}","deployments_url":"https://api.github.com/repos/sinpai/datarockets-finance-app/deployments","created_at":"2018-02-20T08:20:04Z","updated_at":"2018-03-14T12:34:41Z","pushed_at":"2018-03-15T09:13:19Z","git_url":"git://github.com/sinpai/datarockets-finance-app.git","ssh_url":"git@github.com:sinpai/datarockets-finance-app.git","clone_url":"https://github.com/sinpai/datarockets-finance-app.git","svn_url":"https://github.com/sinpai/datarockets-finance-app","homepage":null,"size":320,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/11"},"html":{"href":"https://github.com/sinpai/datarockets-finance-app/pull/11"},"issue":{"href":"https://api.github.com/repos/sinpai/datarockets-finance-app/issues/11"},"comments":{"href":"https://api.github.com/repos/sinpai/datarockets-finance-app/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sinpai/datarockets-finance-app/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/sinpai/datarockets-finance-app/statuses/fd86511ed538dfa57a8cb26f044eca6913f8e00a"}},"author_association":"OWNER"}}
{"actor":{"display_login":"AleksSenkou"}}