Skip to content

Fix sweep findings: user deletion, column mapping, upload/test-send validation, hashed tokens - #12

Merged
op-techy merged 1 commit into
mainfrom
fix/sweep-findings
Dec 2, 2026
Merged

op-techy merged 1 commit into
mainfrom
fix/sweep-findings

Conversation

@op-techy

@op-techy op-techy commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Fixes everything the last end-to-end sweep turned up.

Bugs

  • Deleting a user returned 409 once they had created a template or campaign. V24 makes templates.created_by, campaigns.created_by and users.invited_by ON DELETE SET NULL, so their content stays and just loses its creator.
  • Column mapping was a no-op. POST /api/uploads/{id}/map only stored the mapping. Now an upload whose headers aren't email/first_name/last_name keeps its file (new pending_upload_files table, deleted after import or after a day), and its status shows needsMapping: true, the columns and a first-row preview. /map imports the file with the mapping on the import pool and returns the real counts. The API contract is unchanged; both {"E-mail": "email"} and {"email": "E-mail"} are accepted, and "ignore" skips a column. Bad mappings get 400 (the upload can be mapped again), an already-imported upload 409, a full import pool 503. Works for CSV, XLSX and XLS. Documented in the README.
  • POST /api/templates/upload-html accepted any file. Now only .html/.htm text files (read as UTF-8); anything else gets 400.
  • Campaign test send accepted invalid or empty testEmails. The constraints were on the record but @Valid was missing; now 400.

Minor

  • Password reset and email verification tokens are stored as SHA-256 hashes, not as sent. V25 clears existing tokens, so reset links issued before the deploy stop working (they only lived an hour; users can request a new one).
  • In mock-email mode the log shows the email's text and links rather than the first 200 characters of HTML, so an invite's temporary password and reset links are visible.

Testing

  • New tests: ColumnMappingIntegrationTest (CSV and XLSX, both mapping directions, bad mappings, re-mapping, 404/409), SweepFixesIntegrationTest (user deletion, HTML upload, test send), MockEmailSenderTextTest; AuthServiceTest checks that only the hash is stored.
  • Unit 356/356, integration 36/36, scale 9/9.
  • Docker image built and the end-to-end sweep passed 66/66 against it (V24 and V25 applied cleanly on a fresh database).

…hashed tokens

- Deleting a user who created templates or campaigns no longer fails with 409:
  created_by (and invited_by) are set to NULL (V24).
- Column mapping works: an upload whose headers aren't email/first_name/last_name
  keeps its file (pending_upload_files, cleaned up after a day) and reports
  needsMapping with a first-row preview. POST /api/uploads/{id}/map imports it
  with the mapping and returns the real counts; bad mappings get 400, an
  imported upload 409, a full import pool 503.
- POST /api/templates/upload-html accepts only .html/.htm text files (else 400).
- Campaign test send validates testEmails (non-empty, valid addresses).
- Password reset and email verification tokens are stored as SHA-256 hashes;
  existing tokens are cleared by V25.
- The mock email sender logs the email's text and links, so the invite's
  temporary password is visible in mock mode.
@op-techy
op-techy merged commit 1c74628 into main Dec 2, 2026
2 checks passed
@op-techy
op-techy deleted the fix/sweep-findings branch December 2, 2026 23:52
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