Upload files to "app"
This commit is contained in:
parent
7595cad475
commit
e6ab3af9fc
33
app/credentials.js
Normal file
33
app/credentials.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/* global api */
|
||||||
|
|
||||||
|
async function addCredentials (connectionManager, login, password) {
|
||||||
|
const xmppService = login.split('@').pop()
|
||||||
|
await api.settings.set('connectionManager', connectionManager)
|
||||||
|
await api.settings.set('login', login)
|
||||||
|
await api.keytar.setPassword(xmppService, login, password)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getCredentials () {
|
||||||
|
const credentials = {}
|
||||||
|
credentials.login = (await api.settings.get('login')) || '';
|
||||||
|
if (credentials.login) {
|
||||||
|
credentials.connectionManager = await api.settings.get('connectionManager') || null
|
||||||
|
credentials.xmppService = credentials.login.split('@').pop()
|
||||||
|
credentials.password = await api.keytar.getPassword(credentials.xmppService, credentials.login)
|
||||||
|
}
|
||||||
|
|
||||||
|
return credentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function removeCredentials (login) {
|
||||||
|
const xmppService = login.split('@').pop();
|
||||||
|
await api.keytar.deletePassword(xmppService, login);
|
||||||
|
await api.settings.unset('login');
|
||||||
|
await api.settings.unset('connectionManager');
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
addCredentials,
|
||||||
|
getCredentials,
|
||||||
|
removeCredentials
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user