From 3af9b310000348f14d5a6589889b08450e8cfd3a Mon Sep 17 00:00:00 2001 From: Michael Gielda Date: Tue, 29 Mar 2016 17:56:03 +0200 Subject: [PATCH 1/2] Simpler implementation of HTTP basic auth, fixes #56 --- src/main.js | 12 ++++++++++++ src/package.json | 1 + 2 files changed, 13 insertions(+) diff --git a/src/main.js b/src/main.js index 6c494bb3..4db629fe 100644 --- a/src/main.js +++ b/src/main.js @@ -49,6 +49,18 @@ var mainWindow = null; var trayIcon = null; var willAppQuit = false; +app.on('login', function (event, webContents, request, authInfo, callback) { + event.preventDefault(); + var readlineSync = require('readline-sync'); + console.log("HTTP basic auth requiring login, please provide login data."); + var username = readlineSync.question('Username: '); + var password = readlineSync.question('Password: ', { + hideEchoBack: true + }); + console.log("Replacing default auth behaviour."); + callback(username, password); +}); + // Quit when all windows are closed. app.on('window-all-closed', function() { // On OS X it is common for applications and their menu bar diff --git a/src/package.json b/src/package.json index cc9f27d7..a194b086 100644 --- a/src/package.json +++ b/src/package.json @@ -15,6 +15,7 @@ "react": "^0.14.3", "react-bootstrap": "^0.28.1", "react-dom": "^0.14.3", + "readline-sync": "^1.4.1", "yargs": "^3.31.0" } } From dc644e928546d07a69ffd5d4614f32eb4f34f824 Mon Sep 17 00:00:00 2001 From: Michael Gielda Date: Tue, 29 Mar 2016 18:00:47 +0200 Subject: [PATCH 2/2] Prettified previous commit --- src/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 4db629fe..a6a382d8 100644 --- a/src/main.js +++ b/src/main.js @@ -49,13 +49,13 @@ var mainWindow = null; var trayIcon = null; var willAppQuit = false; -app.on('login', function (event, webContents, request, authInfo, callback) { +app.on('login', function(event, webContents, request, authInfo, callback) { event.preventDefault(); var readlineSync = require('readline-sync'); console.log("HTTP basic auth requiring login, please provide login data."); var username = readlineSync.question('Username: '); var password = readlineSync.question('Password: ', { - hideEchoBack: true + hideEchoBack: true }); console.log("Replacing default auth behaviour."); callback(username, password);