Prototype http authentication
This commit is contained in:
@@ -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) {
|
||||
|
15
src/main.js
15
src/main.js
@@ -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() {
|
||||
|
Reference in New Issue
Block a user