{"action":"created","comment":{"url":"https://api.github.com/repos/codex-team/codex.notes/pulls/comments/168093014","pull_request_review_id":96400546,"id":168093014,"diff_hunk":"@@ -29,119 +44,130 @@ class AuthController {\n    * 2. Google redirect to API server with oauth code\n    * 3. Server gets token and profile info and render page with JWT\n    * 4. Using WebContents Main Process gets JWT from popup\n-   *\n-   * @param {Event} event — see {@link https://electronjs.org/docs/api/ipc-main#event-object}\n-   *\n    */\n-  async googleAuth(event) {\n+  async googleAuth() {\n     /**\n      * Compose random name for auth-channel. We will get JWT from this.\n      * @type {Promise<string>}\n      */\n     let channel = await utils.uniqId();\n \n-    /**\n-     * Open new window with Google Authorisation\n-     * @type {Electron.BrowserWindow}\n-     */\n-    let authWindow = new BrowserWindow({\n-      alwaysOnTop: true,\n-      autoHideMenuBar: true,\n-      webPreferences: {\n-        nodeIntegration: false\n-      }\n-    });\n-\n-    /**\n-     * User can close auth-window\n-     */\n-    authWindow.on('closed', () => {\n-      if (event.returnValue === undefined) {\n-        event.returnValue = false;\n-      }\n-    });\n-\n-    /**\n-     * Start to load Google Auth form\n-     */\n-    authWindow.loadURL('https://accounts.google.com/o/oauth2/v2/auth?' +\n-      'client_id=' + process.env.GOOGLE_CLIENT_ID +\n-      '&scope=email profile' +\n-      '&response_type=code' +\n-      '&redirect_uri=' + process.env.GOOGLE_REDIRECT_URI +\n-      '&state=' + channel // state parameter will be passed to the redirect_uri\n-    );\n-\n-    /**\n-     * Start to listen auth-channel. API will send JWT to this after User's authorisation\n-     */\n-    global.app.sockets.listenChannel(channel, async jwt => {\n+    return new Promise((resolve, reject) => {\n       /**\n-       * Remove quotes\n-       * \"jwt\" -> jwt\n+       * Turns true after successful auth\n+       * @type {boolean}\n        */\n-      jwt = jwt.replace(/\"/g, '');\n+      let authSucceeded = false;\n \n-      /** Trim spaces */\n-      jwt = jwt.trim();\n+      /**\n+       * Open new window with Google Authorisation\n+       * @type {Electron.BrowserWindow}\n+       */\n+      let authWindow = new BrowserWindow({\n+        alwaysOnTop: true,\n+        autoHideMenuBar: true,\n+        webPreferences: {\n+          nodeIntegration: false\n+        }\n+      });\n \n-      /** Decode JWT payload */\n-      let payload = new Buffer(jwt.split('.')[1], 'base64');\n+      /**\n+       * User can close auth-window\n+       */\n+      authWindow.on('closed', () => {\n+        if (authSucceeded) {\n+          resolve(global.user);\n+        } else {\n+          reject();\n+        }\n+      });","path":"src/controllers/auth.js","position":116,"original_position":116,"commit_id":"30dcc203f5c142931e1b307227061d311884e9ef","original_commit_id":"30dcc203f5c142931e1b307227061d311884e9ef","user":{"login":"neSpecc","id":3684889,"avatar_url":"https://avatars0.githubusercontent.com/u/3684889?v=4","gravatar_id":"","url":"https://api.github.com/users/neSpecc","html_url":"https://github.com/neSpecc","followers_url":"https://api.github.com/users/neSpecc/followers","following_url":"https://api.github.com/users/neSpecc/following{/other_user}","gists_url":"https://api.github.com/users/neSpecc/gists{/gist_id}","starred_url":"https://api.github.com/users/neSpecc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neSpecc/subscriptions","organizations_url":"https://api.github.com/users/neSpecc/orgs","repos_url":"https://api.github.com/users/neSpecc/repos","events_url":"https://api.github.com/users/neSpecc/events{/privacy}","received_events_url":"https://api.github.com/users/neSpecc/received_events","type":"User","site_admin":false},"body":"перенести сюда `global.app.sockets.leaveChannel(channel);` чтобы канал закрывался при закрытии окна","created_at":"2018-02-14T07:23:08Z","updated_at":"2018-02-14T07:34:50Z","html_url":"https://github.com/codex-team/codex.notes/pull/138#discussion_r168093014","pull_request_url":"https://api.github.com/repos/codex-team/codex.notes/pulls/138","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/codex-team/codex.notes/pulls/comments/168093014"},"html":{"href":"https://github.com/codex-team/codex.notes/pull/138#discussion_r168093014"},"pull_request":{"href":"https://api.github.com/repos/codex-team/codex.notes/pulls/138"}}},"pull_request":{"url":"https://api.github.com/repos/codex-team/codex.notes/pulls/138","id":167932325,"html_url":"https://github.com/codex-team/codex.notes/pull/138","diff_url":"https://github.com/codex-team/codex.notes/pull/138.diff","patch_url":"https://github.com/codex-team/codex.notes/pull/138.patch","issue_url":"https://api.github.com/repos/codex-team/codex.notes/issues/138","number":138,"state":"open","locked":false,"title":"Collaborators","user":{"login":"gohabereg","id":23050529,"avatar_url":"https://avatars0.githubusercontent.com/u/23050529?v=4","gravatar_id":"","url":"https://api.github.com/users/gohabereg","html_url":"https://github.com/gohabereg","followers_url":"https://api.github.com/users/gohabereg/followers","following_url":"https://api.github.com/users/gohabereg/following{/other_user}","gists_url":"https://api.github.com/users/gohabereg/gists{/gist_id}","starred_url":"https://api.github.com/users/gohabereg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gohabereg/subscriptions","organizations_url":"https://api.github.com/users/gohabereg/orgs","repos_url":"https://api.github.com/users/gohabereg/repos","events_url":"https://api.github.com/users/gohabereg/events{/privacy}","received_events_url":"https://api.github.com/users/gohabereg/received_events","type":"User","site_admin":false},"body":"1. Save new Collaborator to the database\r\n2. Collaborators sync flow","created_at":"2018-02-08T10:31:15Z","updated_at":"2018-02-14T07:34:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"066a14b6ddd213e0d1f55f88b7508e4907a77bb7","assignee":null,"assignees":[],"requested_reviewers":[{"login":"n0str","id":988885,"avatar_url":"https://avatars2.githubusercontent.com/u/988885?v=4","gravatar_id":"","url":"https://api.github.com/users/n0str","html_url":"https://github.com/n0str","followers_url":"https://api.github.com/users/n0str/followers","following_url":"https://api.github.com/users/n0str/following{/other_user}","gists_url":"https://api.github.com/users/n0str/gists{/gist_id}","starred_url":"https://api.github.com/users/n0str/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n0str/subscriptions","organizations_url":"https://api.github.com/users/n0str/orgs","repos_url":"https://api.github.com/users/n0str/repos","events_url":"https://api.github.com/users/n0str/events{/privacy}","received_events_url":"https://api.github.com/users/n0str/received_events","type":"User","site_admin":false},{"login":"talyguryn","id":15259299,"avatar_url":"https://avatars0.githubusercontent.com/u/15259299?v=4","gravatar_id":"","url":"https://api.github.com/users/talyguryn","html_url":"https://github.com/talyguryn","followers_url":"https://api.github.com/users/talyguryn/followers","following_url":"https://api.github.com/users/talyguryn/following{/other_user}","gists_url":"https://api.github.com/users/talyguryn/gists{/gist_id}","starred_url":"https://api.github.com/users/talyguryn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/talyguryn/subscriptions","organizations_url":"https://api.github.com/users/talyguryn/orgs","repos_url":"https://api.github.com/users/talyguryn/repos","events_url":"https://api.github.com/users/talyguryn/events{/privacy}","received_events_url":"https://api.github.com/users/talyguryn/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/codex-team/codex.notes/pulls/138/commits","review_comments_url":"https://api.github.com/repos/codex-team/codex.notes/pulls/138/comments","review_comment_url":"https://api.github.com/repos/codex-team/codex.notes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codex-team/codex.notes/issues/138/comments","statuses_url":"https://api.github.com/repos/codex-team/codex.notes/statuses/30dcc203f5c142931e1b307227061d311884e9ef","head":{"label":"codex-team:collaborators","ref":"collaborators","sha":"30dcc203f5c142931e1b307227061d311884e9ef","user":{"login":"codex-team","id":16060815,"avatar_url":"https://avatars0.githubusercontent.com/u/16060815?v=4","gravatar_id":"","url":"https://api.github.com/users/codex-team","html_url":"https://github.com/codex-team","followers_url":"https://api.github.com/users/codex-team/followers","following_url":"https://api.github.com/users/codex-team/following{/other_user}","gists_url":"https://api.github.com/users/codex-team/gists{/gist_id}","starred_url":"https://api.github.com/users/codex-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codex-team/subscriptions","organizations_url":"https://api.github.com/users/codex-team/orgs","repos_url":"https://api.github.com/users/codex-team/repos","events_url":"https://api.github.com/users/codex-team/events{/privacy}","received_events_url":"https://api.github.com/users/codex-team/received_events","type":"Organization","site_admin":false},"repo":{"id":101810581,"name":"codex.notes","full_name":"codex-team/codex.notes","owner":{"login":"codex-team","id":16060815,"avatar_url":"https://avatars0.githubusercontent.com/u/16060815?v=4","gravatar_id":"","url":"https://api.github.com/users/codex-team","html_url":"https://github.com/codex-team","followers_url":"https://api.github.com/users/codex-team/followers","following_url":"https://api.github.com/users/codex-team/following{/other_user}","gists_url":"https://api.github.com/users/codex-team/gists{/gist_id}","starred_url":"https://api.github.com/users/codex-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codex-team/subscriptions","organizations_url":"https://api.github.com/users/codex-team/orgs","repos_url":"https://api.github.com/users/codex-team/repos","events_url":"https://api.github.com/users/codex-team/events{/privacy}","received_events_url":"https://api.github.com/users/codex-team/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codex-team/codex.notes","description":"CodeX Editor crossplatform desktop version based on Electron","fork":false,"url":"https://api.github.com/repos/codex-team/codex.notes","forks_url":"https://api.github.com/repos/codex-team/codex.notes/forks","keys_url":"https://api.github.com/repos/codex-team/codex.notes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codex-team/codex.notes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codex-team/codex.notes/teams","hooks_url":"https://api.github.com/repos/codex-team/codex.notes/hooks","issue_events_url":"https://api.github.com/repos/codex-team/codex.notes/issues/events{/number}","events_url":"https://api.github.com/repos/codex-team/codex.notes/events","assignees_url":"https://api.github.com/repos/codex-team/codex.notes/assignees{/user}","branches_url":"https://api.github.com/repos/codex-team/codex.notes/branches{/branch}","tags_url":"https://api.github.com/repos/codex-team/codex.notes/tags","blobs_url":"https://api.github.com/repos/codex-team/codex.notes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codex-team/codex.notes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codex-team/codex.notes/git/refs{/sha}","trees_url":"https://api.github.com/repos/codex-team/codex.notes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codex-team/codex.notes/statuses/{sha}","languages_url":"https://api.github.com/repos/codex-team/codex.notes/languages","stargazers_url":"https://api.github.com/repos/codex-team/codex.notes/stargazers","contributors_url":"https://api.github.com/repos/codex-team/codex.notes/contributors","subscribers_url":"https://api.github.com/repos/codex-team/codex.notes/subscribers","subscription_url":"https://api.github.com/repos/codex-team/codex.notes/subscription","commits_url":"https://api.github.com/repos/codex-team/codex.notes/commits{/sha}","git_commits_url":"https://api.github.com/repos/codex-team/codex.notes/git/commits{/sha}","comments_url":"https://api.github.com/repos/codex-team/codex.notes/comments{/number}","issue_comment_url":"https://api.github.com/repos/codex-team/codex.notes/issues/comments{/number}","contents_url":"https://api.github.com/repos/codex-team/codex.notes/contents/{+path}","compare_url":"https://api.github.com/repos/codex-team/codex.notes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codex-team/codex.notes/merges","archive_url":"https://api.github.com/repos/codex-team/codex.notes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codex-team/codex.notes/downloads","issues_url":"https://api.github.com/repos/codex-team/codex.notes/issues{/number}","pulls_url":"https://api.github.com/repos/codex-team/codex.notes/pulls{/number}","milestones_url":"https://api.github.com/repos/codex-team/codex.notes/milestones{/number}","notifications_url":"https://api.github.com/repos/codex-team/codex.notes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codex-team/codex.notes/labels{/name}","releases_url":"https://api.github.com/repos/codex-team/codex.notes/releases{/id}","deployments_url":"https://api.github.com/repos/codex-team/codex.notes/deployments","created_at":"2017-08-29T22:00:25Z","updated_at":"2018-01-15T15:50:44Z","pushed_at":"2018-02-13T22:43:48Z","git_url":"git://github.com/codex-team/codex.notes.git","ssh_url":"git@github.com:codex-team/codex.notes.git","clone_url":"https://github.com/codex-team/codex.notes.git","svn_url":"https://github.com/codex-team/codex.notes","homepage":"https://ifmo.su/editor","size":3025,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","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":20,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":20,"watchers":2,"default_branch":"master"}},"base":{"label":"codex-team:version2.0","ref":"version2.0","sha":"7d072fe6f8266f5eb0c5c28caca1c92bcd9dea1c","user":{"login":"codex-team","id":16060815,"avatar_url":"https://avatars0.githubusercontent.com/u/16060815?v=4","gravatar_id":"","url":"https://api.github.com/users/codex-team","html_url":"https://github.com/codex-team","followers_url":"https://api.github.com/users/codex-team/followers","following_url":"https://api.github.com/users/codex-team/following{/other_user}","gists_url":"https://api.github.com/users/codex-team/gists{/gist_id}","starred_url":"https://api.github.com/users/codex-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codex-team/subscriptions","organizations_url":"https://api.github.com/users/codex-team/orgs","repos_url":"https://api.github.com/users/codex-team/repos","events_url":"https://api.github.com/users/codex-team/events{/privacy}","received_events_url":"https://api.github.com/users/codex-team/received_events","type":"Organization","site_admin":false},"repo":{"id":101810581,"name":"codex.notes","full_name":"codex-team/codex.notes","owner":{"login":"codex-team","id":16060815,"avatar_url":"https://avatars0.githubusercontent.com/u/16060815?v=4","gravatar_id":"","url":"https://api.github.com/users/codex-team","html_url":"https://github.com/codex-team","followers_url":"https://api.github.com/users/codex-team/followers","following_url":"https://api.github.com/users/codex-team/following{/other_user}","gists_url":"https://api.github.com/users/codex-team/gists{/gist_id}","starred_url":"https://api.github.com/users/codex-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codex-team/subscriptions","organizations_url":"https://api.github.com/users/codex-team/orgs","repos_url":"https://api.github.com/users/codex-team/repos","events_url":"https://api.github.com/users/codex-team/events{/privacy}","received_events_url":"https://api.github.com/users/codex-team/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codex-team/codex.notes","description":"CodeX Editor crossplatform desktop version based on Electron","fork":false,"url":"https://api.github.com/repos/codex-team/codex.notes","forks_url":"https://api.github.com/repos/codex-team/codex.notes/forks","keys_url":"https://api.github.com/repos/codex-team/codex.notes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codex-team/codex.notes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codex-team/codex.notes/teams","hooks_url":"https://api.github.com/repos/codex-team/codex.notes/hooks","issue_events_url":"https://api.github.com/repos/codex-team/codex.notes/issues/events{/number}","events_url":"https://api.github.com/repos/codex-team/codex.notes/events","assignees_url":"https://api.github.com/repos/codex-team/codex.notes/assignees{/user}","branches_url":"https://api.github.com/repos/codex-team/codex.notes/branches{/branch}","tags_url":"https://api.github.com/repos/codex-team/codex.notes/tags","blobs_url":"https://api.github.com/repos/codex-team/codex.notes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codex-team/codex.notes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codex-team/codex.notes/git/refs{/sha}","trees_url":"https://api.github.com/repos/codex-team/codex.notes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codex-team/codex.notes/statuses/{sha}","languages_url":"https://api.github.com/repos/codex-team/codex.notes/languages","stargazers_url":"https://api.github.com/repos/codex-team/codex.notes/stargazers","contributors_url":"https://api.github.com/repos/codex-team/codex.notes/contributors","subscribers_url":"https://api.github.com/repos/codex-team/codex.notes/subscribers","subscription_url":"https://api.github.com/repos/codex-team/codex.notes/subscription","commits_url":"https://api.github.com/repos/codex-team/codex.notes/commits{/sha}","git_commits_url":"https://api.github.com/repos/codex-team/codex.notes/git/commits{/sha}","comments_url":"https://api.github.com/repos/codex-team/codex.notes/comments{/number}","issue_comment_url":"https://api.github.com/repos/codex-team/codex.notes/issues/comments{/number}","contents_url":"https://api.github.com/repos/codex-team/codex.notes/contents/{+path}","compare_url":"https://api.github.com/repos/codex-team/codex.notes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codex-team/codex.notes/merges","archive_url":"https://api.github.com/repos/codex-team/codex.notes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codex-team/codex.notes/downloads","issues_url":"https://api.github.com/repos/codex-team/codex.notes/issues{/number}","pulls_url":"https://api.github.com/repos/codex-team/codex.notes/pulls{/number}","milestones_url":"https://api.github.com/repos/codex-team/codex.notes/milestones{/number}","notifications_url":"https://api.github.com/repos/codex-team/codex.notes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codex-team/codex.notes/labels{/name}","releases_url":"https://api.github.com/repos/codex-team/codex.notes/releases{/id}","deployments_url":"https://api.github.com/repos/codex-team/codex.notes/deployments","created_at":"2017-08-29T22:00:25Z","updated_at":"2018-01-15T15:50:44Z","pushed_at":"2018-02-13T22:43:48Z","git_url":"git://github.com/codex-team/codex.notes.git","ssh_url":"git@github.com:codex-team/codex.notes.git","clone_url":"https://github.com/codex-team/codex.notes.git","svn_url":"https://github.com/codex-team/codex.notes","homepage":"https://ifmo.su/editor","size":3025,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","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":20,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":20,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codex-team/codex.notes/pulls/138"},"html":{"href":"https://github.com/codex-team/codex.notes/pull/138"},"issue":{"href":"https://api.github.com/repos/codex-team/codex.notes/issues/138"},"comments":{"href":"https://api.github.com/repos/codex-team/codex.notes/issues/138/comments"},"review_comments":{"href":"https://api.github.com/repos/codex-team/codex.notes/pulls/138/comments"},"review_comment":{"href":"https://api.github.com/repos/codex-team/codex.notes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codex-team/codex.notes/pulls/138/commits"},"statuses":{"href":"https://api.github.com/repos/codex-team/codex.notes/statuses/30dcc203f5c142931e1b307227061d311884e9ef"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"neSpecc"}}