From 4a3775a9ac4242318dd7b91f0012cd756edcad7b Mon Sep 17 00:00:00 2001 From: kamtschatka Date: Sun, 6 Oct 2024 10:06:19 +0200 Subject: feature: Allow disabling password signups (#413) * [Feature Request] Allow to disable default password log in after SSO is configured #406 Added the DISABLE_LOCAL_SIGNUPS that can be used to force OAuth signups only * rename local signups to password signups --------- Co-authored-by: MohamedBassem --- packages/trpc/routers/users.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'packages/trpc') diff --git a/packages/trpc/routers/users.ts b/packages/trpc/routers/users.ts index ba1aee24..736e7e2f 100644 --- a/packages/trpc/routers/users.ts +++ b/packages/trpc/routers/users.ts @@ -29,10 +29,16 @@ export const usersAppRouter = router({ }), ) .mutation(async ({ input, ctx }) => { - if (serverConfig.auth.disableSignups) { + if ( + serverConfig.auth.disableSignups || + serverConfig.auth.disablePasswordSignups + ) { + const errorMessage = serverConfig.auth.disablePasswordSignups + ? "Local Signups are disabled in the server config. Use OAuth instead!" + : "Signups are disabled in server config"; throw new TRPCError({ code: "FORBIDDEN", - message: "Signups are disabled in server config", + message: errorMessage, }); } // TODO: This is racy, but that's probably fine. -- cgit v1.2.3-70-g09d2