From 93d4ee4aadc70f8ffe355ebd8f1972b7f0028ddc Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Wed, 29 Sep 2021 17:46:13 +0100 Subject: [PATCH 1/2] Update existing user in account portal check to only check verified users - fix provision flow --- packages/worker/src/api/controllers/global/users.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/worker/src/api/controllers/global/users.js b/packages/worker/src/api/controllers/global/users.js index 7753370f09..47356b0fd0 100644 --- a/packages/worker/src/api/controllers/global/users.js +++ b/packages/worker/src/api/controllers/global/users.js @@ -53,22 +53,22 @@ async function saveUser( // check budibase users inside the tenant dbUser = await getGlobalUserByEmail(email) if (dbUser != null && (dbUser._id !== _id || Array.isArray(dbUser))) { - throw "Email address already in use." + throw `Email address ${email} already in use.` } // check budibase users in other tenants if (env.MULTI_TENANCY) { dbUser = await getTenantUser(email) if (dbUser != null) { - throw "Email address already in use." + throw `Email address ${email} already in use.` } } // check root account users in account portal if (!env.SELF_HOSTED) { const account = await accounts.getAccount(email) - if (account) { - throw "Email address already in use." + if (account?.verified) { + throw `Email address ${email} already in use.` } } } else { From f089c20d606330407490b11dd9585cc18e585cf0 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Wed, 29 Sep 2021 17:55:08 +0100 Subject: [PATCH 2/2] replace ?. with && --- packages/worker/src/api/controllers/global/users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/worker/src/api/controllers/global/users.js b/packages/worker/src/api/controllers/global/users.js index 47356b0fd0..8d4313fc12 100644 --- a/packages/worker/src/api/controllers/global/users.js +++ b/packages/worker/src/api/controllers/global/users.js @@ -67,7 +67,7 @@ async function saveUser( // check root account users in account portal if (!env.SELF_HOSTED) { const account = await accounts.getAccount(email) - if (account?.verified) { + if (account && account.verified) { throw `Email address ${email} already in use.` } }