From f33c570b1d133f17ce3e321eceed6b82bc049a98 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 8 Jun 2021 14:46:18 +0100 Subject: [PATCH] remove builder role from google auth, only allow google sign in if local account exists --- .../auth/src/middleware/passport/google.js | 22 +++++++++---------- .../src/forms/BooleanField.svelte | 2 ++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/auth/src/middleware/passport/google.js b/packages/auth/src/middleware/passport/google.js index 96a0907536..f84da95e73 100644 --- a/packages/auth/src/middleware/passport/google.js +++ b/packages/auth/src/middleware/passport/google.js @@ -20,16 +20,10 @@ async function authenticate(token, tokenSecret, profile, done) { // use the google profile id dbUser = await db.get(userId) } catch (err) { - console.log("Google user not found. Creating..") - - // create the user const user = { _id: userId, provider: profile.provider, roles: {}, - builder: { - global: true, - }, ...profile._json, } @@ -50,12 +44,18 @@ async function authenticate(token, tokenSecret, profile, done) { user.roles = existing.roles user.builder = existing.builder user.admin = existing.admin + + const response = await db.post(user) + dbUser = user + dbUser._rev = response.rev + } else { + return done( + new Error( + "email does not yet exist. You must set up your local budibase account first." + ), + false + ) } - - const response = await db.post(user) - - dbUser = user - dbUser._rev = response.rev } // authenticate diff --git a/packages/standard-components/src/forms/BooleanField.svelte b/packages/standard-components/src/forms/BooleanField.svelte index 17a3c563bc..2d12a89228 100644 --- a/packages/standard-components/src/forms/BooleanField.svelte +++ b/packages/standard-components/src/forms/BooleanField.svelte @@ -9,6 +9,8 @@ let fieldState let fieldApi + + // $: if (fieldApi && $fieldState.value === null) fieldApi.setValue(false)