Browse Source
Merge pull request #3389 from Budibase/fix/sync-issue
Quick fix for sync issue
master
Michael Drury
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
15 additions and
10 deletions
-
packages/server/src/api/controllers/user.js
|
|
|
@ -97,6 +97,7 @@ exports.syncUser = async function (ctx) { |
|
|
|
.map(([appId]) => appId) |
|
|
|
} |
|
|
|
for (let prodAppId of prodAppIds) { |
|
|
|
const roleId = roles[prodAppId] |
|
|
|
const devAppId = getDevelopmentAppID(prodAppId) |
|
|
|
for (let appId of [prodAppId, devAppId]) { |
|
|
|
if (!(await doesDatabaseExist(appId))) { |
|
|
|
@ -115,17 +116,21 @@ exports.syncUser = async function (ctx) { |
|
|
|
tableId: InternalTables.USER_METADATA, |
|
|
|
} |
|
|
|
} |
|
|
|
let combined |
|
|
|
if (deleting) { |
|
|
|
combined = { |
|
|
|
...metadata, |
|
|
|
status: UserStatus.INACTIVE, |
|
|
|
metadata: BUILTIN_ROLE_IDS.PUBLIC, |
|
|
|
} |
|
|
|
} else { |
|
|
|
combined = combineMetadataAndUser(user, metadata) |
|
|
|
// assign the roleId for the metadata doc
|
|
|
|
if (roleId) { |
|
|
|
metadata.roleId = roleId |
|
|
|
} |
|
|
|
let combined = !deleting |
|
|
|
? combineMetadataAndUser(user, metadata) |
|
|
|
: { |
|
|
|
...metadata, |
|
|
|
status: UserStatus.INACTIVE, |
|
|
|
metadata: BUILTIN_ROLE_IDS.PUBLIC, |
|
|
|
} |
|
|
|
// if its null then there was no updates required
|
|
|
|
if (combined) { |
|
|
|
await db.put(combined) |
|
|
|
} |
|
|
|
await db.put(combined) |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.body = { |
|
|
|
|