mirror of https://github.com/Fabio286/antares.git
refactor: moving from keytar to local storage due issues on Linux
This commit is contained in:
parent
239cb4488f
commit
0081a4167c
|
@ -96,12 +96,17 @@ else {
|
||||||
|
|
||||||
// create main BrowserWindow when electron is ready
|
// create main BrowserWindow when electron is ready
|
||||||
app.on('ready', async () => {
|
app.on('ready', async () => {
|
||||||
|
try {
|
||||||
let key = await keytar.getPassword('antares', 'user');
|
let key = await keytar.getPassword('antares', 'user');
|
||||||
|
|
||||||
if (!key) {
|
if (!key) {
|
||||||
key = crypto.randomBytes(16).toString('hex');
|
key = crypto.randomBytes(16).toString('hex');
|
||||||
keytar.setPassword('antares', 'user', key);
|
keytar.setPassword('antares', 'user', key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
|
||||||
mainWindow = createMainWindow();
|
mainWindow = createMainWindow();
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,14 @@ export default () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('get-key', async event => {
|
ipcMain.on('get-key', async event => {
|
||||||
const key = await keytar.getPassword('antares', 'user');
|
let key = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
key = await keytar.getPassword('antares', 'user');
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
event.returnValue = key;
|
event.returnValue = key;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
import Store from 'electron-store';
|
import Store from 'electron-store';
|
||||||
|
import crypto from 'crypto';
|
||||||
import Application from '../../ipc-api/Application';
|
import Application from '../../ipc-api/Application';
|
||||||
const key = Application.getKey();
|
const key = Application.getKey() || localStorage.getItem('key');
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
localStorage.setItem('key', crypto.randomBytes(16).toString('hex'));
|
||||||
|
else
|
||||||
|
localStorage.setItem('key', key);
|
||||||
|
|
||||||
const persistentStore = new Store({
|
const persistentStore = new Store({
|
||||||
name: 'connections',
|
name: 'connections',
|
||||||
|
|
Loading…
Reference in New Issue