feat: 🚩 Add webhook url call on user creation
This commit is contained in:
@ -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
|
||||
|
@ -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 |
|
||||
|
||||
</p></details>
|
||||
|
||||
<details><summary>Webhooks</summary>
|
||||
<p>
|
||||
|
||||
| Parameter | Default | Description |
|
||||
| ------------------------ | ------- | --------------------------------------------------------------------------------------------- |
|
||||
| USER_CREATED_WEBHOOK_URL | -- | Webhook URL called whenever a new user is created (used for importing a new SendGrid contact) |
|
||||
|
||||
</p></details>
|
||||
|
Reference in New Issue
Block a user