Fixing issue with google callback URL not being used when it was previously set.
This commit is contained in:
parent
9995177492
commit
938f94e68f
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { Label } from "@budibase/bbui"
|
import { Label, Checkbox } from "@budibase/bbui"
|
||||||
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
||||||
|
|
||||||
export let parameters
|
export let parameters
|
||||||
|
|
|
@ -187,7 +187,6 @@
|
||||||
`Please fill in all required ${ConfigTypes.Google} fields`
|
`Please fill in all required ${ConfigTypes.Google} fields`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
delete element.config.callbackURL
|
|
||||||
calls.push(api.post(`/api/global/configs`, element))
|
calls.push(api.post(`/api/global/configs`, element))
|
||||||
googleSaveButtonDisabled = true
|
googleSaveButtonDisabled = true
|
||||||
originalGoogleDoc = cloneDeep(providers.google)
|
originalGoogleDoc = cloneDeep(providers.google)
|
||||||
|
|
|
@ -15,7 +15,11 @@ const {
|
||||||
} = require("@budibase/auth/tenancy")
|
} = require("@budibase/auth/tenancy")
|
||||||
const env = require("../../../environment")
|
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`
|
let callbackUrl = `/api/global/auth`
|
||||||
if (isMultiTenant()) {
|
if (isMultiTenant()) {
|
||||||
callbackUrl += `/${getTenantId()}`
|
callbackUrl += `/${getTenantId()}`
|
||||||
|
@ -116,12 +120,12 @@ exports.logout = async ctx => {
|
||||||
*/
|
*/
|
||||||
exports.googlePreAuth = async (ctx, next) => {
|
exports.googlePreAuth = async (ctx, next) => {
|
||||||
const db = getGlobalDB()
|
const db = getGlobalDB()
|
||||||
let callbackUrl = googleCallbackUrl()
|
|
||||||
|
|
||||||
const config = await authPkg.db.getScopedConfig(db, {
|
const config = await authPkg.db.getScopedConfig(db, {
|
||||||
type: Configs.GOOGLE,
|
type: Configs.GOOGLE,
|
||||||
workspace: ctx.query.workspace,
|
workspace: ctx.query.workspace,
|
||||||
})
|
})
|
||||||
|
let callbackUrl = googleCallbackUrl(config)
|
||||||
const strategy = await google.strategyFactory(config, callbackUrl)
|
const strategy = await google.strategyFactory(config, callbackUrl)
|
||||||
|
|
||||||
return passport.authenticate(strategy, {
|
return passport.authenticate(strategy, {
|
||||||
|
@ -131,12 +135,12 @@ exports.googlePreAuth = async (ctx, next) => {
|
||||||
|
|
||||||
exports.googleAuth = async (ctx, next) => {
|
exports.googleAuth = async (ctx, next) => {
|
||||||
const db = getGlobalDB()
|
const db = getGlobalDB()
|
||||||
const callbackUrl = googleCallbackUrl()
|
|
||||||
|
|
||||||
const config = await authPkg.db.getScopedConfig(db, {
|
const config = await authPkg.db.getScopedConfig(db, {
|
||||||
type: Configs.GOOGLE,
|
type: Configs.GOOGLE,
|
||||||
workspace: ctx.query.workspace,
|
workspace: ctx.query.workspace,
|
||||||
})
|
})
|
||||||
|
const callbackUrl = googleCallbackUrl(config)
|
||||||
const strategy = await google.strategyFactory(config, callbackUrl)
|
const strategy = await google.strategyFactory(config, callbackUrl)
|
||||||
|
|
||||||
return passport.authenticate(
|
return passport.authenticate(
|
||||||
|
|
Loading…
Reference in New Issue