Skip to content

fix: SJIP-1606 scope resetAllConsents to live users - #126

Merged
evans-g-crsj merged 1 commit into
mainfrom
fix/SJIP-1606-tighten-reset-all-consents
Sep 4, 2026
Merged

evans-g-crsj merged 1 commit into
mainfrom
fix/SJIP-1606-tighten-reset-all-consents

Conversation

@evans-g-crsj

Copy link
Copy Markdown
Contributor

PUT /admin/resetAllConsents ran with an empty where, so it cleared consent
flags on soft-deleted rows too, and returning: true made Postgres send back all
35 columns of every updated row only for the count to be read off the array length.

  • where: { deleted: false } — a soft-deleted row has a randomized
    keycloak_id that matches no Keycloak subject, so it can never log in and
    re-consent. Resetting it was unreachable work that also overwrote its
    updated_date (which deleteUser leaves as the user's last real profile edit).
  • dropped returning: true — sequelize still returns the count as result[0],
    derived from the driver's rowCount instead of rows.length.

⚠️ The updated count in the response is now smaller: it counts live users reset,
not total table rows.

…RETURNING

The admin consent reset ran with an empty where clause, so it also
cleared the consent flags on soft-deleted users, and returning:true made
Postgres send back all 35 columns of every updated row only for the
count to be read off the array length and the rows discarded.

Filter on deleted:false and drop returning. Sequelize still yields the
affected-row count as result[0] without it -- derived from the driver's
rowCount rather than rows.length -- so the route's {updated: N} payload
keeps its shape. N now counts live users reset rather than total table
rows.

The flag was inherited verbatim in b6aa8b7, which collapsed the per-user
updateRolesAndDataUsages loop into one bulk update and emptied the where
clause while carrying returning:true across. It was already unused there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@evans-g-crsj
evans-g-crsj merged commit 5e77b6c into main Sep 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants