Gate replays.

This commit is contained in:
Mike Cao committed 2026-03-15 18:03:36 -07:00
1 parent 534af98809
commit 6e1a05f686
8 files changed
+109 -6

No files matched your search

+16 -2
View File
@@ -1,3 +1,4 @@
import { fetchAccount } from '@/lib/load';
import { parseRequest } from '@/lib/request';
import { json } from '@/lib/response';
import { getAllUserTeams } from '@/queries/prisma';
@@ -9,7 +10,20 @@ export async function POST(request: Request) {
return error();
}
const teams = await getAllUserTeams(auth.user.id);
const user = { ...auth.user };
const teams = await getAllUserTeams(user.id);
return json({ ...auth.user, teams });
if (process.env.CLOUD_MODE) {
const account = await fetchAccount(user.id);
if (account) {
user.subscription = {
isPro: account.isPro || false,
isBusiness: account.isBusiness || false,
hasSubscription: account.hasSubscription || false,
};
}
}
return json({ ...user, teams });
}
+9
View File
@@ -4,6 +4,7 @@ import { z } from 'zod';
import { secret } from '@/lib/crypto';
import { getClientInfo, hasBlockedIp } from '@/lib/detect';
import { parseToken } from '@/lib/jwt';
import { fetchAccount } from '@/lib/load';
import { parseRequest } from '@/lib/request';
import { badRequest, forbidden, json, serverError } from '@/lib/response';
import { getWebsite } from '@/queries/prisma';
@@ -60,6 +61,14 @@ export async function POST(request: Request) {
return json({ ok: false, reason: 'replay_disabled' });
}
if (process.env.CLOUD_MODE) {
const account = await fetchAccount(website.userId);
if (!account?.isBusiness) {
return forbidden({ message: 'Business subscription required.' });
}
}
// Client info for bot/IP checks
const { ip, userAgent } = await getClientInfo(request, {});