1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
import { ipcRenderer } from 'electron';
import { observable } from 'mobx';
import BasicAuthComponent from './Component';
const debug = require('debug')('Franz:feature:basicAuth');
const defaultState = {
isModalVisible: true,
service: null,
authInfo: null,
};
export const state = observable(defaultState);
export function resetState() {
Object.assign(state, defaultState);
}
export default function initialize() {
debug('Initialize basicAuth feature');
window.franz.features.basicAuth = {
state,
};
ipcRenderer.on('feature:basic-auth-request', (e, data) => {
debug(e, data);
// state.serviceId = data.serviceId;
state.authInfo = data.authInfo;
state.isModalVisible = true;
});
}
export function mainIpcHandler(mainWindow, authInfo) {
debug('Sending basic auth call', authInfo);
mainWindow.webContents.send('feature:basic-auth-request', {
authInfo,
});
}
export function sendCredentials(user, password) {
debug('Sending credentials to main', user, password);
ipcRenderer.send('feature-basic-auth-credentials', {
user,
password,
});
}
export function cancelLogin() {
debug('Cancel basic auth event');
ipcRenderer.send('feature-basic-auth-cancel');
}
export const Component = BasicAuthComponent;
|