From 2dca8ab46e9b67e57ed1080c6a7e4804f533f2a7 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 6 Sep 2021 15:14:46 +0100 Subject: [PATCH] Quick fix for backwards compat, enabling multi-tenancy on a previously single tenancy environment. --- packages/auth/src/cache/user.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/auth/src/cache/user.js b/packages/auth/src/cache/user.js index 4a19da489f..e0936182a7 100644 --- a/packages/auth/src/cache/user.js +++ b/packages/auth/src/cache/user.js @@ -18,6 +18,10 @@ exports.getUser = async (userId, tenantId = null) => { user = await getGlobalDB(tenantId).get(userId) client.store(userId, user, EXPIRY_SECONDS) } + if (user && !user.tenantId && tenantId) { + // make sure the tenant ID is always correct/set + user.tenantId = tenantId + } return user }