Skip to content

Prevent user creation from replacing existing accounts - #186

Closed
nirmalhk7 wants to merge 1 commit into
NTARI-RAND:mainfrom
nirmalhk7:nirmal/agrinet-user-create-integrity
Closed

nirmalhk7 wants to merge 1 commit into
NTARI-RAND:mainfrom
nirmalhk7:nirmal/agrinet-user-create-integrity

Conversation

@nirmalhk7

Copy link
Copy Markdown
Contributor

POST /users accepted a caller-selected account ID and issued an unconditional DynamoDB PutItem, allowing creation to replace an existing account record. Generate the account ID server-side, make creation conditional on attribute_not_exists(id), and return HTTP 409 if a generated ID already exists. Existing role handling and authentication behavior are unchanged; this fix does not claim working login takeover or introduce a new role policy.

Regressions verify that a caller-selected victim ID leaves the existing record intact, successful creation returns the server-generated ID, and a generated-ID collision returns 409 without replacing the original record.

Validation: the three affected route cases failed before the fix and all 5 targeted user-route Jest tests pass afterward, using real Express, Supertest, and bcrypt with simulated DynamoDB conditional writes. Tests ran from an isolated backend copy using existing installed dependencies because origin/main tracks dependency stubs. The existing Node suite also passes all 6 tests; whitespace and syntax checks pass. No live DynamoDB or production verification performed. One DCO-signed commit, based independently on origin/main.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
@nirmalhk7

Copy link
Copy Markdown
Contributor Author

As I understand, superseded by #197, hence closing.

@nirmalhk7 nirmalhk7 closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant