From ff5c3683fcac487301b31ab6b855694c6f9d59d5 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Mon, 30 May 2022 17:08:00 +0200 Subject: [PATCH] =?UTF-8?q?feat(auth):=20=F0=9F=9B=82=20Disable=20new=20us?= =?UTF-8?q?er=20signups?= 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.mdx | 1 + 2 files changed, 6 insertions(+) diff --git a/apps/builder/pages/api/auth/adapter.ts b/apps/builder/pages/api/auth/adapter.ts index 04af3f974..39b543cfd 100644 --- a/apps/builder/pages/api/auth/adapter.ts +++ b/apps/builder/pages/api/auth/adapter.ts @@ -29,6 +29,11 @@ export function CustomAdapter(p: PrismaClient): Adapter { const workspaceInvitations = await p.workspaceInvitation.findMany({ where: { email: user.email }, }) + if ( + process.env.DISABLE_SIGNUP === 'true' && + process.env.ADMIN_EMAIL !== data.email + ) + throw Error('New users are forbidden') const createdUser = await p.user.create({ data: { ...data, diff --git a/apps/docs/docs/self-hosting/configuration.mdx b/apps/docs/docs/self-hosting/configuration.mdx index a89b24aa2..d8864c487 100644 --- a/apps/docs/docs/self-hosting/configuration.mdx +++ b/apps/docs/docs/self-hosting/configuration.mdx @@ -31,6 +31,7 @@ Both apps have their own environment config files. Here is an exhaustive list of | NEXTAUTH_URL | http://localhost:3000 | The builder base URL. Should be the publicly accessible URL (i.e. `https://typebot.domain.com`) | | NEXT_PUBLIC_VIEWER_URL | http://localhost:3001 | The viewer base URL. Should be the publicly accessible URL (i.e. `https://bot.domain.com`) | | NEXTAUTH_URL_INTERNAL | -- | The internal builder base URL. You have to set it only when `NEXTAUTH_URL` isn't publicly accessible | +| DISABLE_SIGNUP | false | To disable new sign ups but still be able to sign in with existing users or admin email |

Email (Auth, notifications)