From 39b01431e026a33d08ad2b0885942351ecb99b73 Mon Sep 17 00:00:00 2001
From: Baptiste Arnaud
Date: Wed, 23 Mar 2022 15:47:53 +0100
Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=9A=A9=20Add=20webhook=20url=20ca?=
=?UTF-8?q?ll=20on=20user=20creation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
apps/builder/pages/api/auth/adapter.ts | 5 +++++
apps/docs/docs/self-hosting/configuration.md | 9 +++++++++
2 files changed, 14 insertions(+)
diff --git a/apps/builder/pages/api/auth/adapter.ts b/apps/builder/pages/api/auth/adapter.ts
index 4d4369c3e..9e65ea517 100644
--- a/apps/builder/pages/api/auth/adapter.ts
+++ b/apps/builder/pages/api/auth/adapter.ts
@@ -3,6 +3,7 @@ import { PrismaClient, Prisma, Invitation, Plan } from 'db'
import { randomUUID } from 'crypto'
import type { Adapter, AdapterUser } from 'next-auth/adapters'
import cuid from 'cuid'
+import { got } from 'got'
export function CustomAdapter(p: PrismaClient): Adapter {
return {
@@ -19,6 +20,10 @@ export function CustomAdapter(p: PrismaClient): Adapter {
plan: process.env.ADMIN_EMAIL === data.email ? Plan.PRO : Plan.FREE,
},
})
+ if (process.env.USER_CREATED_WEBHOOK_URL)
+ await got.post(process.env.USER_CREATED_WEBHOOK_URL, {
+ json: data,
+ })
if (invitations.length > 0)
await convertInvitationsToCollaborations(p, user, invitations)
return createdUser
diff --git a/apps/docs/docs/self-hosting/configuration.md b/apps/docs/docs/self-hosting/configuration.md
index 57991ea99..dd58b4a0a 100644
--- a/apps/docs/docs/self-hosting/configuration.md
+++ b/apps/docs/docs/self-hosting/configuration.md
@@ -181,3 +181,12 @@ These can also be added to the `viewer` environment
| SLEEKPLAN_SSO_KEY | -- | Sleekplan SSO key used to automatically authenticate a user in Sleekplan |
+
+Webhooks
+
+
+| Parameter | Default | Description |
+| ------------------------ | ------- | --------------------------------------------------------------------------------------------- |
+| USER_CREATED_WEBHOOK_URL | -- | Webhook URL called whenever a new user is created (used for importing a new SendGrid contact) |
+
+