Merge pull request #14926 from Budibase/fix/no-account-holder
Don't throw if no account-holder is found
This commit is contained in:
commit
220d57027b
|
@ -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) => {
|
||||||
const users = await userSdk.core.getAllUsers()
|
try {
|
||||||
const response = await userSdk.core.getExistingAccounts(
|
const users = await userSdk.core.getAllUsers()
|
||||||
users.map(u => u.email)
|
const response = await userSdk.core.getExistingAccounts(
|
||||||
)
|
users.map(u => u.email)
|
||||||
const holder = response[0]
|
)
|
||||||
if (!holder) {
|
const holder = response[0]
|
||||||
return
|
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue