Merge pull request #14926 from Budibase/fix/no-account-holder

Don't throw if no account-holder is found
This commit is contained in:
Martin McKeaveney 2024-10-31 08:58:55 +00:00 committed by GitHub
commit 220d57027b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 9 deletions

View File

@ -312,16 +312,21 @@ export const tenantUserLookup = async (ctx: any) => {
* So the account holder may not be found until further pagination has occurred * So the account holder may not be found until further pagination has occurred
*/ */
export const accountHolderLookup = async (ctx: Ctx) => { export const accountHolderLookup = async (ctx: Ctx) => {
try {
const users = await userSdk.core.getAllUsers() const users = await userSdk.core.getAllUsers()
const response = await userSdk.core.getExistingAccounts( const response = await userSdk.core.getExistingAccounts(
users.map(u => u.email) users.map(u => u.email)
) )
const holder = response[0] const holder = response[0]
if (!holder) { if (!holder) {
ctx.body = null
return return
} }
holder._id = users.find(u => u.email === holder.email)?._id holder._id = users.find(u => u.email === holder.email)?._id
ctx.body = holder ctx.body = holder
} catch (e) {
ctx.body = null
}
} }
/* /*