Added remove account function to config manager.

This commit is contained in:
Daniel Scalzi 2018-04-08 20:56:44 -04:00
parent 9b4a2d4ef9
commit 8d682b15b3
No known key found for this signature in database
GPG Key ID: 5CA2F145B63535F9
2 changed files with 26 additions and 3 deletions

View File

@ -194,6 +194,31 @@ exports.addAuthAccount = function(uuid, accessToken, username, displayName){
return config.authenticationDatabase[uuid] return config.authenticationDatabase[uuid]
} }
/**
* Remove an authenticated account from the database. If the account
* was also the selected account, a new one will be selected. If there
* are no accounts, the selected account will be null.
*
* @param {string} uuid The uuid of the authenticated account.
*
* @returns {boolean} True if the account was removed, false if it never existed.
*/
exports.removeAuthAccount = function(uuid){
if(config.authenticationDatabase[uuid] != null){
delete config.authenticationDatabase[uuid]
if(config.selectedAccount === uuid){
const keys = Object.keys(config.authenticationDatabase)
if(keys.length > 0){
config.selectedAccount = keys[0]
} else {
config.selectedAccount = null
}
}
return true
}
return false
}
/** /**
* Get the currently selected authenticated account. * Get the currently selected authenticated account.
* *

View File

@ -67,9 +67,7 @@
"perMachine": true, "perMachine": true,
"allowElevation": true, "allowElevation": true,
"installerIcon": "build/icon.ico", "installerIcon": "build/icon.ico",
"uninstallerIcon": "build/icon.ico", "uninstallerIcon": "build/icon.ico"
"installerHeader": "build/icon.ico",
"installerHeaderIcon": "build/icon.ico"
}, },
"mac": { "mac": {
"target": "dmg", "target": "dmg",