Repository navigation
Reject RSVPs to events that don't exist and stop trusting the per_ID sent by the client - #12
Merged
Merged
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10
POST /api/attendeenow returns 404 for events that don't exist, and it setsper_IDon the server instead of taking it from the request. The new tests and the existing backend tests pass. I didn't run the browser checks.What changed
In
exports.createinbackend/controllers/attendee.controller.js:db.event.findByPk(req.body.evt_ID)) together. If the event doesn't exist it answers 404{ message: "Event not found." }and creates nothing.per_IDfrom the server: it now comes from the logged-in user's linked member, found withdb.person.findOne({ where: { user_name: user.username } }), the same lookupauthJwt.jsand signin use. If the login has no linked member it isnull.req.body.per_IDis ignored.contribution, andrefreshAttendancework as before. The last.thennow only sends a response if the 404 hasn't already been sent.How I verified it
backend/test/attendee.test.js(node:test). It stubs the model methods onrequire("../models"), so no database is needed. It checks three cases:attendee.createis never called;attendee.creategets the linked person'sper_ID(7), not the one in the body (42);per_ID: null.cd backend && npm testpasses all 6 tests (3 new, 3 existing). The worktree had nonode_modules, so I rannpm cifirst; until then both test files failed withCannot find module 'sequelize'.What to check
contribution. Old rows that already hold a forgedper_IDkeep it until the user cancels and RSVPs again. The issue said to leave this path alone, so I didn't add a cleanup.calendar.check.js) should cover it.Codex review
per_IDin place. Rows created before this change can still point to another member, and deleting that member deletes the mislinked RSVP. Set the server-resolvedper_IDon updates as well as inserts, repair existing mismatches, and add a regression test for the update path.evt_ID, such as an array or object, passes the presence check and makes Sequelize return an error that the endpoint sends as a 500. Validate and normalizeevt_IDto a positive integer before querying, return 400 for malformed values, and use the normalized ID for both lookup and persistence.Fixes after the review
I fixed both findings and committed them on HEAD as
5965d08. All 9 backend tests pass (npm test). The backend has no lint script, and I didn't touch the frontend, so I didn't run its lint.1. Updating an RSVP leaves its old
per_ID— fixed.per_IDalong with the new contribution (backend/controllers/attendee.controller.js:46). Before, only new RSVPs got the server's value.backend/attendee-per-id.jsruns once at server startup, after the existing database-upgrade steps. It sets every RSVP'sper_IDto the member record linked to itsusername. It's added toserver.jsand to thebundlescript so it deploys with the backend.username, so it can't wipe links it has no way to check.per_IDbecomes null. That matches what the server now stores for new RSVPs from such users.per_IDis 42 and checks it is relinked to the caller's 7.2. A malformed
evt_IDgives a 500 — fixed.evt_IDis now converted to a number up front. If it isn't a positive whole number, the request gets a 400 and nothing is saved."abc",0,-1and1.5each get a 400 and create nothing. Another checks that"5"is saved as the number5.[5]converts to5and is accepted. It still ends up as a valid ID, so I left it.The 400 message changed from "Content can NOT be empty!" to "evt_ID must be a positive integer." Nothing in the frontend checks for the old text.