diff --git a/images/press.png b/images/press.png index ee0115bc4..45fc187a7 100644 Binary files a/images/press.png and b/images/press.png differ diff --git a/package.json b/package.json index 906ff6c98..8ad73e121 100644 --- a/package.json +++ b/package.json @@ -93,8 +93,8 @@ }, "devDependencies": { "babel-eslint": "=4.0.10", - "electron-packager": "=5.0.2", - "electron-prebuilt": "=0.31.0", + "electron-packager": "=5.1.0", + "electron-prebuilt": "=0.32.3", "eslint": "=1.2.1", "grunt": "=0.4.5", "grunt-contrib-clean": "=0.6.0", diff --git a/src/js/__tests__/components/login.js b/src/js/__tests__/components/login.js index 67c2c27a4..b03f494b7 100644 --- a/src/js/__tests__/components/login.js +++ b/src/js/__tests__/components/login.js @@ -31,6 +31,14 @@ describe('Test for Login Component', function () { ); } + if (event == 'did-get-redirect-request') { + callback( + 'did-get-redirect-request', + 'http://www.github.com/?code=123123123', + 'http://www.github.com/?code=123123123' + ); + } + } }, on: function () { @@ -38,6 +46,9 @@ describe('Test for Login Component', function () { }, close: function () { return; + }, + destroy: function () { + return; } }; }; @@ -141,6 +152,14 @@ describe('Test for Login Component - Callback with Error', function () { ); } + if (event == 'did-get-redirect-request') { + callback( + 'did-get-redirect-request', + 'http://www.github.com/?error=FAILURE', + 'http://www.github.com/?error=FAILURE' + ); + } + } }, on: function (event, callback) { @@ -148,6 +167,9 @@ describe('Test for Login Component - Callback with Error', function () { }, close: function () { return; + }, + destroy: function (argument) { + return; } }; }; diff --git a/src/js/components/login.js b/src/js/components/login.js index 3f63dfd36..9ca663961 100644 --- a/src/js/components/login.js +++ b/src/js/components/login.js @@ -27,20 +27,30 @@ var Login = React.createClass({ width: 800, height: 600, show: true, - 'node-integration': false + 'web-preferences': { + 'node-integration': false + } }); var githubUrl = 'https://github.com/login/oauth/authorize?'; var authUrl = githubUrl + 'client_id=' + options.client_id + '&scope=' + options.scope; authWindow.loadUrl(authUrl); authWindow.webContents.on('will-navigate', function (event, url) { + handleCallback(url); + }); + + authWindow.webContents.on('did-get-redirect-request', function (event, oldUrl, newUrl) { + handleCallback(newUrl); + }); + + function handleCallback (url) { var raw_code = /code=([^&]*)/.exec(url) || null; var code = (raw_code && raw_code.length > 1) ? raw_code[1] : null; var error = /\?error=(.+)$/.exec(url); if (code || error) { // Close the browser if code found or error - authWindow.close(); + authWindow.destroy(); } // If there is a code, proceed to get token from github @@ -50,13 +60,12 @@ var Login = React.createClass({ alert('Oops! Something went wrong and we couldn\'t' + 'log you in using Github. Please try again.'); } - - }); + } // If "Done" button is pressed, hide "Loading" authWindow.on('close', function () { - authWindow = null; - }, false); + authWindow.destroy(); + }); },