From 95fc3a0825795b15a387707ac8cb2cb0df3f4c27 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Fri, 22 Mar 2024 15:31:55 +0000 Subject: feature: Add an option to disable new signups --- apps/web/components/signin/CredentialsForm.tsx | 8 +++++++- apps/web/lib/clientConfig.tsx | 3 +++ apps/web/server/auth.ts | 6 ------ 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'apps/web') diff --git a/apps/web/components/signin/CredentialsForm.tsx b/apps/web/components/signin/CredentialsForm.tsx index 8e1423eb..5e3b4de9 100644 --- a/apps/web/components/signin/CredentialsForm.tsx +++ b/apps/web/components/signin/CredentialsForm.tsx @@ -13,6 +13,7 @@ import { } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import { useClientConfig } from "@/lib/clientConfig"; import { api } from "@/lib/trpc"; import { zodResolver } from "@hookform/resolvers/zod"; import { TRPCClientError } from "@trpc/client"; @@ -100,6 +101,7 @@ function SignIn() { } function SignUp() { + const clientConfig = useClientConfig(); const form = useForm>({ resolver: zodResolver(zSignUpSchema), }); @@ -201,7 +203,11 @@ function SignUp() { ); }} /> - + Sign Up diff --git a/apps/web/lib/clientConfig.tsx b/apps/web/lib/clientConfig.tsx index fac76d3b..10ca1010 100644 --- a/apps/web/lib/clientConfig.tsx +++ b/apps/web/lib/clientConfig.tsx @@ -4,6 +4,9 @@ import type { ClientConfig } from "@hoarder/shared/config"; export const ClientConfigCtx = createContext({ demoMode: false, + auth: { + disableSignups: false, + }, }); export function useClientConfig() { diff --git a/apps/web/server/auth.ts b/apps/web/server/auth.ts index 767bc7e8..acc3745c 100644 --- a/apps/web/server/auth.ts +++ b/apps/web/server/auth.ts @@ -5,12 +5,10 @@ import NextAuth, { getServerSession, NextAuthOptions, } from "next-auth"; -import AuthentikProvider from "next-auth/providers/authentik"; import CredentialsProvider from "next-auth/providers/credentials"; import { Provider } from "next-auth/providers/index"; import { db } from "@hoarder/db"; -import serverConfig from "@hoarder/shared/config"; import { validatePassword } from "@hoarder/trpc/auth"; declare module "next-auth/jwt" { @@ -63,10 +61,6 @@ const providers: Provider[] = [ }), ]; -if (serverConfig.auth.authentik) { - providers.push(AuthentikProvider(serverConfig.auth.authentik)); -} - export const authOptions: NextAuthOptions = { // https://github.com/nextauthjs/next-auth/issues/9493 adapter: DrizzleAdapter(db) as Adapter, -- cgit v1.2.3-70-g09d2