Append auth on verification

This commit is contained in:
Adria Navarro 2023-05-16 09:50:23 +02:00
parent bc21484223
commit b5890b788f
1 changed files with 8 additions and 2 deletions

View File

@ -25,6 +25,7 @@ import {
DatasourcePlus, DatasourcePlus,
} from "@budibase/types" } from "@budibase/types"
import sdk from "../../sdk" import sdk from "../../sdk"
import _ from "lodash"
function getErrorTables(errors: any, errorType: string) { function getErrorTables(errors: any, errorType: string) {
return Object.entries(errors) return Object.entries(errors)
@ -126,8 +127,13 @@ export async function fetch(ctx: UserCtx) {
export async function verify( export async function verify(
ctx: UserCtx<VerifyDatasourceRequest, VerifyDatasourceResponse> ctx: UserCtx<VerifyDatasourceRequest, VerifyDatasourceResponse>
) { ) {
const datasource = ctx.request.body.datasource const { datasource } = ctx.request.body
const connector = (await getConnector(datasource)) as IntegrationBase
const { config: { auth } = {} } = await sdk.datasources.get(datasource._id!)
const connector = await getConnector(
_.merge({ config: { auth } }, datasource)
)
if (!connector.testConnection) { if (!connector.testConnection) {
ctx.throw(400, "Connection information verification not supported") ctx.throw(400, "Connection information verification not supported")
} }