Skip to content

Commit

Permalink
Merge pull request Budibase#14926 from Budibase/fix/no-account-holder
Browse files Browse the repository at this point in the history
Don't throw if no account-holder is found
  • Loading branch information
shogunpurple authored Oct 31, 2024
2 parents eba7f01 + 4a036fa commit 220d570
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/worker/src/api/controllers/global/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,21 @@ export const tenantUserLookup = async (ctx: any) => {
* So the account holder may not be found until further pagination has occurred
*/
export const accountHolderLookup = async (ctx: Ctx) => {
const users = await userSdk.core.getAllUsers()
const response = await userSdk.core.getExistingAccounts(
users.map(u => u.email)
)
const holder = response[0]
if (!holder) {
return
try {
const users = await userSdk.core.getAllUsers()
const response = await userSdk.core.getExistingAccounts(
users.map(u => u.email)
)
const holder = response[0]
if (!holder) {
ctx.body = null
return
}
holder._id = users.find(u => u.email === holder.email)?._id
ctx.body = holder
} catch (e) {
ctx.body = null
}
holder._id = users.find(u => u.email === holder.email)?._id
ctx.body = holder
}

/*
Expand Down

0 comments on commit 220d570

Please sign in to comment.