Fixing some issues highlighted by worker test cases.
This commit is contained in:
parent
88c07d28eb
commit
4e13dde657
|
@ -23,10 +23,6 @@ exports.doInTenant = (tenantId, task) => {
|
|||
// invoke the task
|
||||
const result = task()
|
||||
|
||||
// clear down the tenant id manually for extra safety
|
||||
// this should also happen automatically when the call exits
|
||||
cls.setOnContext(TENANT_ID, null)
|
||||
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
|
|
@ -268,6 +268,7 @@ exports.invite = async ctx => {
|
|||
if (!userInfo) {
|
||||
userInfo = {}
|
||||
}
|
||||
userInfo.tenantId = getTenantId()
|
||||
await sendEmail(email, EmailTemplatePurpose.INVITATION, {
|
||||
subject: "{{ company }} platform invitation",
|
||||
info: userInfo,
|
||||
|
@ -292,8 +293,6 @@ exports.inviteAccept = async ctx => {
|
|||
},
|
||||
info.tenantId
|
||||
)
|
||||
// this will flesh out the body response
|
||||
await exports.save(ctx)
|
||||
} catch (err) {
|
||||
ctx.throw(400, "Unable to create new user, invitation invalid.")
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ const { newid } = require("../../../../../../auth/src/hashing")
|
|||
const { TENANT_ID } = require("./structures")
|
||||
const auth = require("@budibase/auth")
|
||||
const CouchDB = require("../../../../db")
|
||||
const { doInTenant } = require("@budibase/auth/tenancy")
|
||||
auth.init(CouchDB)
|
||||
|
||||
class TestConfiguration {
|
||||
|
@ -40,7 +41,9 @@ class TestConfiguration {
|
|||
if (params) {
|
||||
request.params = params
|
||||
}
|
||||
await controlFunc(request)
|
||||
await doInTenant(TENANT_ID, () => {
|
||||
return controlFunc(request)
|
||||
})
|
||||
return request.body
|
||||
}
|
||||
|
||||
|
@ -96,7 +99,9 @@ class TestConfiguration {
|
|||
}
|
||||
|
||||
async getUser(email) {
|
||||
return getGlobalUserByEmail(email, TENANT_ID)
|
||||
return doInTenant(TENANT_ID, () => {
|
||||
return getGlobalUserByEmail(email)
|
||||
})
|
||||
}
|
||||
|
||||
async createUser(email = "test@test.com", password = "test") {
|
||||
|
|
Loading…
Reference in New Issue