aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/basicAuth/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/basicAuth/index.js')
-rw-r--r--src/features/basicAuth/index.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/features/basicAuth/index.js b/src/features/basicAuth/index.js
new file mode 100644
index 000000000..99abf0d11
--- /dev/null
+++ b/src/features/basicAuth/index.js
@@ -0,0 +1,68 @@
1import { ipcRenderer } from 'electron';
2import { observable } from 'mobx';
3
4import BasicAuthComponent from './Component';
5
6const debug = require('debug')('Franz:feature:basicAuth');
7
8const defaultState = {
9 isModalVisible: false,
10 service: null,
11 authInfo: null,
12};
13
14export const state = observable(defaultState);
15
16export function resetState() {
17 Object.assign(state, defaultState);
18 console.log('reset state', state);
19}
20
21export default function initialize(stores) {
22 debug('Initialize basicAuth feature');
23
24 window.franz.features.basicAuth = {
25 state,
26 };
27
28 ipcRenderer.on('feature:basic-auth-request', (e, data) => {
29 debug(e, data);
30 // state.serviceId = data.serviceId;
31 state.authInfo = data.authInfo;
32 state.isModalVisible = true;
33 });
34
35 // autorun(() => {
36 // // if (state.serviceId) {
37 // // const service = stores.services.one(state.serviceId);
38 // // if (service) {
39 // // state.service = service;
40 // // }
41 // // }
42 // });
43}
44
45export function mainIpcHandler(mainWindow, authInfo) {
46 debug('Sending basic auth call', authInfo);
47
48 mainWindow.webContents.send('feature:basic-auth-request', {
49 authInfo,
50 });
51}
52
53export function sendCredentials(user, password) {
54 debug('Sending credentials to main', user, password);
55
56 ipcRenderer.send('feature-basic-auth-credentials', {
57 user,
58 password,
59 });
60}
61
62export function cancelLogin() {
63 debug('Cancel basic auth event');
64
65 ipcRenderer.send('feature-basic-auth-cancel');
66}
67
68export const Component = BasicAuthComponent;