Refactored to use loadAccounts

This commit is contained in:
José Oliveira 2021-02-09 13:13:45 +00:00 committed by Josh Harvey
parent 93b6c0e086
commit fcfe16d5eb

View file

@ -54,17 +54,8 @@ function loadAccounts (schemaVersion) {
} }
function showAccounts (schemaVersion) { function showAccounts (schemaVersion) {
const sql = `select data return loadAccounts(schemaVersion)
from user_config .then(accounts => {
where type=$1
and schema_version=$2
and valid
order by id desc
limit 1`
return db.oneOrNone(sql, ['accounts', schemaVersion || NEW_SETTINGS_LOADER_SCHEMA_VERSION])
.then(res => {
const accounts = _.compose(_.defaultTo({}), _.get('data.accounts'))(res)
const filledSecretPaths = _.compact(_.map(path => { const filledSecretPaths = _.compact(_.map(path => {
if (!_.isEmpty(_.get(path, accounts))) { if (!_.isEmpty(_.get(path, accounts))) {
return path return path