Prototype http authentication

This commit is contained in:
Yuya Ochiai
2016-04-21 22:43:18 +09:00
parent f8678fbec3
commit 58f1ec5f9a
2 changed files with 22 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ const ListGroupItem = ReactBootstrap.ListGroupItem;
const electron = require('electron');
const remote = electron.remote;
const ipcRenderer = electron.ipcRenderer;
const osLocale = require('os-locale');
const fs = require('fs');
@@ -25,6 +26,12 @@ const settings = require('../common/settings');
remote.getCurrentWindow().removeAllListeners('focus');
ipcRenderer.on('login-request', function(event, request, authInfo) {
setTimeout(() => {
ipcRenderer.send('login-credentials', request, 'user', 'password');
}, 10000);
});
// New window should disable nodeIntergration.
const originalWindowOpen = window.open;
window.open = function(url, name, features) {

View File

@@ -139,6 +139,21 @@ app.on('certificate-error', function(event, webContents, url, error, certificate
}
});
const loginCallbackMap = new Map();
ipc.on('login-credentials', function(event, request, user, password) {
const callback = loginCallbackMap.get(JSON.stringify(request));
if (callback != null) {
callback(user, password);
}
})
app.on('login', function(event, webContents, request, authInfo, callback) {
event.preventDefault();
loginCallbackMap.set(JSON.stringify(request), callback);
mainWindow.webContents.send('login-request', request, authInfo);
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {