fix: don't use unpublished org in any credit context (#22600)
* fix: don't use unpublished org for any credit context * type error * fix test * update
This commit is contained in:
1 parent
2c91c0e309
commit
c8de8ca681
6 files changed
+20
-10
No files matched your search
@@ -34,9 +34,9 @@ export const buyCreditsHandler = async ({ ctx, input }: BuyCreditsOptions) => {
|
||||
}
|
||||
} else {
|
||||
// if user id is part of a team, user can't buy credits for themselves
|
||||
const memberships = await MembershipRepository.findAllAcceptedMemberships(ctx.user.id);
|
||||
const memberships = await MembershipRepository.findAllAcceptedPublishedTeamMemberships(ctx.user.id);
|
||||
|
||||
if (memberships.length > 0) {
|
||||
if (!memberships || memberships.length > 0) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
});
|
||||
|
||||
@@ -25,9 +25,9 @@ export const getAllCreditsHandler = async ({ ctx, input }: GetAllCreditsOptions)
|
||||
}
|
||||
} else {
|
||||
//if user is part of team, don't return any credits if teamId is not given
|
||||
const memberships = await MembershipRepository.findAllAcceptedMemberships(ctx.user.id);
|
||||
const memberships = await MembershipRepository.findAllAcceptedPublishedTeamMemberships(ctx.user.id);
|
||||
|
||||
if (memberships.length > 0) {
|
||||
if (!memberships || memberships.length > 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user