Silownie: dolaczenie do prywatnej silowni odrzucane (403) - tylko zaproszenia

This commit is contained in:
tisachi
2026-10-11 16:17:29 +02:00
parent c626898cd5
commit 69435d899b
2 changed files with 17 additions and 1 deletions

View File

@@ -158,10 +158,11 @@ export async function rateGym(
return { vote: existing?.vote === vote ? null : vote, up, down };
}
/** Join an existing gym (creates a MEMBER membership). */
/** Join an existing gym (creates a MEMBER membership). Private gyms are invitation-only. */
export async function joinGym(prisma: PrismaClient, userId: string, gymId: string) {
const gym = await prisma.gym.findUnique({ where: { id: gymId } });
if (!gym) throw notFound('Gym not found');
if (gym.isPrivate) throw forbidden('Private gyms are invitation-only');
const existing = await prisma.gymMembership.findUnique({
where: { userId_gymId: { userId, gymId } },
});