mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-20 01:55:26 -05:00
Validate permission to report results
This commit is contained in:
@@ -96,6 +96,7 @@ const reportWinnersParamsSchema = z.object({
|
||||
});
|
||||
|
||||
export const action: ActionFunction = async ({ request, params }) => {
|
||||
const user = await requireUser(request);
|
||||
const parsedParams = reportWinnersParamsSchema.parse(params);
|
||||
const parsedInput = await safeParseRequestFormData({
|
||||
request,
|
||||
@@ -108,6 +109,16 @@ export const action: ActionFunction = async ({ request, params }) => {
|
||||
};
|
||||
}
|
||||
|
||||
const event = notFoundIfFalsy(db.calendarEvents.findById(parsedParams.id));
|
||||
validate(
|
||||
canReportCalendarEventWinners({
|
||||
user,
|
||||
event,
|
||||
startTimes: event.startTimes,
|
||||
}),
|
||||
401
|
||||
);
|
||||
|
||||
db.calendarEvents.upsertReportedScores({
|
||||
eventId: parsedParams.id,
|
||||
participantCount: parsedInput.data.participantCount,
|
||||
|
||||
Reference in New Issue
Block a user