Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent double-spending of user-uploaded planning areas
When setting project grid from shapefile, the operation should fail if the projectId of the planning area being updated does not match the planning area's own id. Explanation: When creating a project with a custom grid or planning area, the flow is: - first, user uploads a shapefile, app gets the id of the planning area that was created from it (if they upload a grid file, the planning area is backported from it, as a union of all the geometries) - when actually requesting to create a project, the app sends the `planningAreaId` obtained in the previous step The issue here is - since planning areas should not be linked to a random project, but we don’t yet have a `projectId` by the time the planning area is created, we set its `projectId` to the same value as its `id`. But then, when we actually create the project, in `SetProjectGridFromShapefileHandler` while we link the previously-updated planning area to the project, we don’t check if `projectId === id`, which ends up allowing to reuse the same planning area in case several requests to create a project with the same planning area id (for example, as a side effect of MRXNM-484 and sibling stories), which in practice ends up “stealing” planning areas created by earlier projects that use the same `planningAreaId` in the `POST` request payload.
- Loading branch information