remove builder role from google auth, only allow google sign in if local account exists
This commit is contained in:
parent
ba17e0bc9c
commit
f33c570b1d
|
@ -20,16 +20,10 @@ async function authenticate(token, tokenSecret, profile, done) {
|
||||||
// use the google profile id
|
// use the google profile id
|
||||||
dbUser = await db.get(userId)
|
dbUser = await db.get(userId)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Google user not found. Creating..")
|
|
||||||
|
|
||||||
// create the user
|
|
||||||
const user = {
|
const user = {
|
||||||
_id: userId,
|
_id: userId,
|
||||||
provider: profile.provider,
|
provider: profile.provider,
|
||||||
roles: {},
|
roles: {},
|
||||||
builder: {
|
|
||||||
global: true,
|
|
||||||
},
|
|
||||||
...profile._json,
|
...profile._json,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,12 +44,18 @@ async function authenticate(token, tokenSecret, profile, done) {
|
||||||
user.roles = existing.roles
|
user.roles = existing.roles
|
||||||
user.builder = existing.builder
|
user.builder = existing.builder
|
||||||
user.admin = existing.admin
|
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
|
// authenticate
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
|
||||||
|
// $: if (fieldApi && $fieldState.value === null) fieldApi.setValue(false)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
|
|
Loading…
Reference in New Issue