1
0
Fork 0
mirror of synced 2024-06-14 08:24:48 +12:00

Fixing issue with google callback URL not being used when it was previously set.

This commit is contained in:
mike12345567 2021-08-05 11:27:51 +01:00
parent 83462a0eee
commit 78a3a1cd09
3 changed files with 8 additions and 5 deletions

View file

@ -1,5 +1,5 @@
<script>
import { Label } from "@budibase/bbui"
import { Label, Checkbox } from "@budibase/bbui"
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
export let parameters

View file

@ -187,7 +187,6 @@
`Please fill in all required ${ConfigTypes.Google} fields`
)
} else {
delete element.config.callbackURL
calls.push(api.post(`/api/global/configs`, element))
googleSaveButtonDisabled = true
originalGoogleDoc = cloneDeep(providers.google)

View file

@ -15,7 +15,11 @@ const {
} = require("@budibase/auth/tenancy")
const env = require("../../../environment")
function googleCallbackUrl() {
function googleCallbackUrl(config) {
// incase there is a callback URL from before
if (config && config.callbackURL) {
return config.callbackURL
}
let callbackUrl = `/api/global/auth`
if (isMultiTenant()) {
callbackUrl += `/${getTenantId()}`
@ -116,12 +120,12 @@ exports.logout = async ctx => {
*/
exports.googlePreAuth = async (ctx, next) => {
const db = getGlobalDB()
let callbackUrl = googleCallbackUrl()
const config = await authPkg.db.getScopedConfig(db, {
type: Configs.GOOGLE,
workspace: ctx.query.workspace,
})
let callbackUrl = googleCallbackUrl(config)
const strategy = await google.strategyFactory(config, callbackUrl)
return passport.authenticate(strategy, {
@ -131,12 +135,12 @@ exports.googlePreAuth = async (ctx, next) => {
exports.googleAuth = async (ctx, next) => {
const db = getGlobalDB()
const callbackUrl = googleCallbackUrl()
const config = await authPkg.db.getScopedConfig(db, {
type: Configs.GOOGLE,
workspace: ctx.query.workspace,
})
const callbackUrl = googleCallbackUrl(config)
const strategy = await google.strategyFactory(config, callbackUrl)
return passport.authenticate(