diff --git a/apps/api/src/controllers/oauth-callback.controller.tsx b/apps/api/src/controllers/oauth-callback.controller.tsx index f626e6491..445aef391 100644 --- a/apps/api/src/controllers/oauth-callback.controller.tsx +++ b/apps/api/src/controllers/oauth-callback.controller.tsx @@ -112,6 +112,7 @@ async function handleNewUser({ ); } + const user = await db.user.create({ data: { email: oauthUser.email, diff --git a/packages/trpc/index.ts b/packages/trpc/index.ts index 2c70a8203..a78a2c330 100644 --- a/packages/trpc/index.ts +++ b/packages/trpc/index.ts @@ -1,3 +1,5 @@ export * from './src/root'; export * from './src/trpc'; export { getProjectAccess } from './src/access'; +export { getIsRegistrationAllowed } from './src/routers/auth'; +export { TRPCAccessError } from './src/errors' diff --git a/packages/trpc/src/routers/auth.ts b/packages/trpc/src/routers/auth.ts index 8d83bdf4f..52e6dd556 100644 --- a/packages/trpc/src/routers/auth.ts +++ b/packages/trpc/src/routers/auth.ts @@ -53,7 +53,7 @@ const TWO_FACTOR_CHALLENGE_TTL_SECONDS = 5 * 60; const zProvider = z.enum(['email', 'google', 'github']); -async function getIsRegistrationAllowed(inviteId?: string | null) { +export async function getIsRegistrationAllowed(inviteId?: string | null) { // ALLOW_REGISTRATION is always undefined in cloud if (process.env.ALLOW_REGISTRATION === undefined) { return true; @@ -68,9 +68,6 @@ async function getIsRegistrationAllowed(inviteId?: string | null) { // 2. If there is an invite, check if it is valid if (inviteId) { - if (process.env.ALLOW_INVITATION === 'false') { - return false; - } const invite = await db.invite.findUnique({ where: { @@ -95,13 +92,6 @@ export const authRouter = createTRPCRouter({ signInOAuth: publicProcedure .input(z.object({ provider: zProvider, inviteId: z.string().nullish() })) .mutation(async ({ input, ctx }) => { - const isRegistrationAllowed = await getIsRegistrationAllowed( - input.inviteId - ); - - if (!isRegistrationAllowed) { - throw TRPCAccessError('Registrations are not allowed'); - } const { provider } = input;