From 64cd5b6e4b6db64aef81ecb1443084c174650094 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 19 Feb 2022 13:57:56 +0100 Subject: [PATCH] fix: Gitlab webhooks fixed --- src/hooks.ts | 2 +- .../databases/[id]/_Databases/_Databases.svelte | 2 +- src/routes/sources/[id]/_Gitlab.svelte | 13 ++++++++----- src/routes/webhooks/gitlab/index.ts | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/hooks.ts b/src/hooks.ts index 7bb2d8060..bdd1f9234 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -18,7 +18,7 @@ export const handle = handleSession( try { if (event.locals.cookies) { let gitlabToken = event.locals.cookies.gitlabToken || null; - let ghToken = event.locals.cookies.ghToken; + let ghToken = event.locals.cookies.ghToken || null; if (event.locals.cookies['kit.session']) { const { permission, teamId, userId } = await getUserDetails(event, false); const newSession = { diff --git a/src/routes/databases/[id]/_Databases/_Databases.svelte b/src/routes/databases/[id]/_Databases/_Databases.svelte index 611936d59..83c15a496 100644 --- a/src/routes/databases/[id]/_Databases/_Databases.svelte +++ b/src/routes/databases/[id]/_Databases/_Databases.svelte @@ -36,7 +36,7 @@ function generateUrl() { return browser - ? `${database.type}://${database.type === 'redis' ? ':' : ''}${ + ? `${database.type}://${ databaseDbUser ? databaseDbUser + ':' : '' }${databaseDbUserPassword}@${ isPublic diff --git a/src/routes/sources/[id]/_Gitlab.svelte b/src/routes/sources/[id]/_Gitlab.svelte index 01de75424..0a39fcf72 100644 --- a/src/routes/sources/[id]/_Gitlab.svelte +++ b/src/routes/sources/[id]/_Gitlab.svelte @@ -121,12 +121,15 @@ Scopes required: +
- api (Access the authenticated user's API) +
- read_repository (Allows read-only access to the repository) +
- email (Allows read-only access to the user's primary email address using OpenID Connect)
-
For extra security, you can add Expire access tokens!" +
For extra security, you can set Expire access tokens! +

Webhook URL: {window.location + .origin}/webhooks/gitlab +
But if you will set a custom domain name for Coolify, use that instead." />
diff --git a/src/routes/webhooks/gitlab/index.ts b/src/routes/webhooks/gitlab/index.ts index 9f953bc88..f3d930ace 100644 --- a/src/routes/webhooks/gitlab/index.ts +++ b/src/routes/webhooks/gitlab/index.ts @@ -21,8 +21,8 @@ export const get: RequestHandler = async (event) => { const code = event.url.searchParams.get('code'); const state = event.url.searchParams.get('state'); try { + const { fqdn } = await db.listSettings(); const application = await db.getApplication({ id: state, teamId }); - const { fqdn } = application; const { appId, appSecret } = application.gitSource.gitlabApp; const { htmlUrl } = application.gitSource;