add conditional (#20057)
This commit is contained in:
1 parent
0e5a0bfa7b
commit
a6b6898697
1 file changed
+13
@@ -85,6 +85,19 @@ export const chargeCardHandler = async ({ ctx, input }: ChargeCardHandlerOptions
|
||||
? { teamId: booking.eventType.teamId }
|
||||
: { userId: ctx.user.id };
|
||||
|
||||
if (booking.eventType?.teamId) {
|
||||
const userIsInTeam = await prisma.membership.findFirst({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
teamId: booking.eventType?.teamId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!userIsInTeam) {
|
||||
throw new TRPCError({ code: "UNAUTHORIZED", message: "User is not in team" });
|
||||
}
|
||||
}
|
||||
|
||||
const paymentCredential = await prisma.credential.findFirst({
|
||||
where: {
|
||||
...idToSearchObject,
|
||||
|
||||
Reference in new issue
Block a user