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,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();
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue