Fix user metadata update
This commit is contained in:
parent
a0cc4a1b21
commit
ef4b1dd32b
|
@ -7,14 +7,17 @@ const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
||||||
exports.getFullUser = async (ctx, userId) => {
|
exports.getFullUser = async (ctx, userId) => {
|
||||||
const global = await getGlobalUser(userId)
|
const global = await getGlobalUser(userId)
|
||||||
let metadata = {}
|
let metadata = {}
|
||||||
|
|
||||||
|
// always prefer the user metadata _id and _rev
|
||||||
|
delete global._id
|
||||||
|
delete global._rev
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// this will throw an error if the db doesn't exist, or there is no appId
|
// this will throw an error if the db doesn't exist, or there is no appId
|
||||||
const db = getAppDB()
|
const db = getAppDB()
|
||||||
metadata = await db.get(userId)
|
metadata = await db.get(userId)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// it is fine if there is no user metadata, just remove global db info
|
// it is fine if there is no user metadata yet
|
||||||
delete global._id
|
|
||||||
delete global._rev
|
|
||||||
}
|
}
|
||||||
delete metadata.csrfToken
|
delete metadata.csrfToken
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue