1
1
mirror of https://github.com/Fabio286/antares.git synced 2024-12-25 00:10:41 +01:00

refactor: moving from keytar to local storage due issues on Linux

This commit is contained in:
Fabio Di Stasio 2021-03-08 17:35:43 +01:00
parent 239cb4488f
commit 0081a4167c
3 changed files with 24 additions and 6 deletions

View File

@ -96,11 +96,16 @@ else {
// create main BrowserWindow when electron is ready
app.on('ready', async () => {
let key = await keytar.getPassword('antares', 'user');
try {
let key = await keytar.getPassword('antares', 'user');
if (!key) {
key = crypto.randomBytes(16).toString('hex');
keytar.setPassword('antares', 'user', key);
if (!key) {
key = crypto.randomBytes(16).toString('hex');
keytar.setPassword('antares', 'user', key);
}
}
catch (err) {
console.log(err);
}
mainWindow = createMainWindow();

View File

@ -7,7 +7,14 @@ export default () => {
});
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;
});
};

View File

@ -1,7 +1,13 @@
'use strict';
import Store from 'electron-store';
import crypto from 'crypto';
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({
name: 'connections',