From 507401b75ce69905759bd56b18d2404ba0698667 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 11 Oct 2022 12:42:35 +0100 Subject: [PATCH] Fix user metadata update --- packages/server/src/utilities/users.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/server/src/utilities/users.js b/packages/server/src/utilities/users.js index 3fa222e677..498b934605 100644 --- a/packages/server/src/utilities/users.js +++ b/packages/server/src/utilities/users.js @@ -7,14 +7,17 @@ const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles") exports.getFullUser = async (ctx, userId) => { const global = await getGlobalUser(userId) let metadata = {} + + // always prefer the user metadata _id and _rev + delete global._id + delete global._rev + try { // this will throw an error if the db doesn't exist, or there is no appId const db = getAppDB() metadata = await db.get(userId) } catch (err) { - // it is fine if there is no user metadata, just remove global db info - delete global._id - delete global._rev + // it is fine if there is no user metadata yet } delete metadata.csrfToken return {