aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/basicAuth/store.ts
blob: 0713ff5727fb2601b977c9e1ac84e9ad18a3a990 (plain) (blame)
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
import { observable } from 'mobx';
import { ipcRenderer } from 'electron';

const debug = require('debug')('Ferdi:feature:basicAuth');

const defaultState = {
  isModalVisible: true,
  service: null,
  authInfo: null,
};

export const state = observable(defaultState);

export function resetState() {
  Object.assign(state, defaultState);
}
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');
}