From 8d682b15b33bc898fc110a12c620851fa1e68b22 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sun, 8 Apr 2018 20:56:44 -0400 Subject: [PATCH] Added remove account function to config manager. --- app/assets/js/configmanager.js | 25 +++++++++++++++++++++++++ package.json | 4 +--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/assets/js/configmanager.js b/app/assets/js/configmanager.js index 4ce6dc8..3a82cc9 100644 --- a/app/assets/js/configmanager.js +++ b/app/assets/js/configmanager.js @@ -194,6 +194,31 @@ exports.addAuthAccount = function(uuid, accessToken, username, displayName){ 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. * diff --git a/package.json b/package.json index a6c2d21..e8d2dcd 100644 --- a/package.json +++ b/package.json @@ -67,9 +67,7 @@ "perMachine": true, "allowElevation": true, "installerIcon": "build/icon.ico", - "uninstallerIcon": "build/icon.ico", - "installerHeader": "build/icon.ico", - "installerHeaderIcon": "build/icon.ico" + "uninstallerIcon": "build/icon.ico" }, "mac": { "target": "dmg",