fix: validate swipe restaurant ids against room candidates
This commit is contained in:
@@ -23,8 +23,10 @@ export const POST = apiHandler(async (req, { params }) => {
|
||||
}
|
||||
|
||||
const restaurantIndex = data.restaurants.findIndex((r) => r.id === rid);
|
||||
if (restaurantIndex < 0) {
|
||||
throw new ApiError("restaurantId 不存在于该房间候选列表", 400);
|
||||
}
|
||||
const alreadySwiped =
|
||||
restaurantIndex >= 0 &&
|
||||
restaurantIndex < (data.swipeCounts[userId] ?? 0);
|
||||
|
||||
if (alreadySwiped) return data;
|
||||
|
||||
Reference in New Issue
Block a user