Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/api/src/controllers/oauth-callback.controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ async function handleNewUser({
);
}


const user = await db.user.create({
data: {
email: oauthUser.email,
Expand Down
2 changes: 2 additions & 0 deletions packages/trpc/index.ts
Original file line number Diff line number Diff line change
@@ -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'
12 changes: 1 addition & 11 deletions packages/trpc/src/routers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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: {
Expand All @@ -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;

Expand Down