|
|
|
@ -6,13 +6,11 @@ const { |
|
|
|
} = require("@budibase/auth/db") |
|
|
|
const { hash, getGlobalUserByEmail } = require("@budibase/auth").utils |
|
|
|
const { UserStatus, EmailTemplatePurpose } = require("../../../constants") |
|
|
|
const { DEFAULT_TENANT_ID } = require("@budibase/auth/constants") |
|
|
|
const { checkInviteCode } = require("../../../utilities/redis") |
|
|
|
const { sendEmail } = require("../../../utilities/email") |
|
|
|
const { user: userCache } = require("@budibase/auth/cache") |
|
|
|
const { invalidateSessions } = require("@budibase/auth/sessions") |
|
|
|
const CouchDB = require("../../../db") |
|
|
|
const env = require("../../../environment") |
|
|
|
const { |
|
|
|
getGlobalDB, |
|
|
|
getTenantId, |
|
|
|
@ -251,25 +249,14 @@ exports.find = async ctx => { |
|
|
|
ctx.body = user |
|
|
|
} |
|
|
|
|
|
|
|
exports.tenantLookup = async ctx => { |
|
|
|
exports.tenantUserLookup = async ctx => { |
|
|
|
const id = ctx.params.id |
|
|
|
// lookup, could be email or userId, either will return a doc
|
|
|
|
const db = new CouchDB(PLATFORM_INFO_DB) |
|
|
|
let tenantId = null |
|
|
|
try { |
|
|
|
const doc = await db.get(id) |
|
|
|
if (doc && doc.tenantId) { |
|
|
|
tenantId = doc.tenantId |
|
|
|
} |
|
|
|
ctx.body = await db.get(id) |
|
|
|
} catch (err) { |
|
|
|
if (!env.MULTI_TENANCY) { |
|
|
|
tenantId = DEFAULT_TENANT_ID |
|
|
|
} else { |
|
|
|
ctx.throw(400, "No tenant found.") |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.body = { |
|
|
|
tenantId, |
|
|
|
ctx.throw(400, "No tenant user found.") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|