Fixing some issues highlighted by worker test cases.

This commit is contained in:
mike12345567 2021-08-03 17:14:17 +01:00
parent 88c07d28eb
commit 4e13dde657
3 changed files with 8 additions and 8 deletions

View File

@ -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
})
}

View File

@ -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.")
}

View File

@ -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") {