fix invites
This commit is contained in:
@@ -63,6 +63,9 @@ export async function getCurrentProjects(organizationSlug: string) {
|
||||
where: {
|
||||
organizationSlug,
|
||||
},
|
||||
orderBy: {
|
||||
eventsCount: 'desc',
|
||||
},
|
||||
}),
|
||||
db.member.findMany({
|
||||
where: {
|
||||
@@ -73,6 +76,7 @@ export async function getCurrentProjects(organizationSlug: string) {
|
||||
db.projectAccess.findMany({
|
||||
where: {
|
||||
userId: session.userId,
|
||||
organizationId: organizationSlug,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -29,9 +29,13 @@ export const organizationRouter = createTRPCRouter({
|
||||
inviteUser: protectedProcedure
|
||||
.input(zInviteUser)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const userExists = await db.user.findUnique({
|
||||
const email = input.email.toLowerCase();
|
||||
const userExists = await db.user.findFirst({
|
||||
where: {
|
||||
email: input.email,
|
||||
email: {
|
||||
equals: email,
|
||||
mode: 'insensitive',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -39,7 +43,7 @@ export const organizationRouter = createTRPCRouter({
|
||||
|
||||
if (!userExists) {
|
||||
const ticket = await clerkClient.invitations.createInvitation({
|
||||
emailAddress: input.email,
|
||||
emailAddress: email,
|
||||
notify: true,
|
||||
});
|
||||
invitationId = ticket.id;
|
||||
@@ -47,7 +51,7 @@ export const organizationRouter = createTRPCRouter({
|
||||
|
||||
return db.member.create({
|
||||
data: {
|
||||
email: input.email,
|
||||
email,
|
||||
organizationId: input.organizationSlug,
|
||||
role: input.role,
|
||||
invitedById: ctx.session.userId,
|
||||
|
||||
Reference in New Issue
Block a user