diff --git a/packages/server/src/api/controllers/user.js b/packages/server/src/api/controllers/user.js index b44983cf9e..60bb7e8adb 100644 --- a/packages/server/src/api/controllers/user.js +++ b/packages/server/src/api/controllers/user.js @@ -4,9 +4,7 @@ const { getUserMetadataParams, } = require("../../db/utils") const { InternalTables } = require("../../db/utils") -const { - addAppRoleToUser, -} = require("../../utilities/workerRequests") +const { addAppRoleToUser } = require("../../utilities/workerRequests") const { getGlobalUsers, getGlobalUser } = require("../../utilities/global") const { getFullUser } = require("../../utilities/users") diff --git a/packages/server/src/db/linkedRows/index.js b/packages/server/src/db/linkedRows/index.js index 37d76b5c1f..e8b215358f 100644 --- a/packages/server/src/db/linkedRows/index.js +++ b/packages/server/src/db/linkedRows/index.js @@ -11,10 +11,7 @@ const { const { flatten } = require("lodash") const CouchDB = require("../../db") const { FieldTypes } = require("../../constants") -const { - getMultiIDParams, - USER_METDATA_PREFIX, -} = require("../../db/utils") +const { getMultiIDParams, USER_METDATA_PREFIX } = require("../../db/utils") const { partition } = require("lodash") const { getGlobalUsers } = require("../../utilities/global") @@ -70,20 +67,21 @@ async function getFullLinkedDocs(appId, links) { row => row.doc ) // need to handle users as specific cases - let [users, other] = partition(linked, linkRow => linkRow._id.startsWith(USER_METDATA_PREFIX)) + let [users, other] = partition(linked, linkRow => + linkRow._id.startsWith(USER_METDATA_PREFIX) + ) const globalUsers = await getGlobalUsers(appId, users) users = users.map(user => { - const globalUser = globalUsers.find(globalUser => globalUser && user._id.includes(globalUser._id)) + const globalUser = globalUsers.find( + globalUser => globalUser && user._id.includes(globalUser._id) + ) return { ...globalUser, // doing user second overwrites the id and rev (always metadata) ...user, } }) - return [ - ...other, - ...users, - ] + return [...other, ...users] } /** diff --git a/packages/server/src/utilities/global.js b/packages/server/src/utilities/global.js index 47482f3abd..eda0e61cff 100644 --- a/packages/server/src/utilities/global.js +++ b/packages/server/src/utilities/global.js @@ -43,16 +43,22 @@ exports.getGlobalUsers = async (appId = null, users = null) => { row => row.doc ) } else { - globalUsers = (await db.allDocs(getGlobalUserParams(null,{ - include_docs: true, - }))).rows.map(row => row.doc) + globalUsers = ( + await db.allDocs( + getGlobalUserParams(null, { + include_docs: true, + }) + ) + ).rows.map(row => row.doc) } - globalUsers = globalUsers.filter(user => user != null).map(user => { - delete user.password - return user - }) + globalUsers = globalUsers + .filter(user => user != null) + .map(user => { + delete user.password + return user + }) if (!appId) { return globalUsers } return globalUsers.map(user => exports.updateAppRole(appId, user)) -} \ No newline at end of file +}