Skip to content

feat: require password confirmation to delete account (#66) - #68

Merged
thermcampos merged 3 commits into
mainfrom
feat/66-require-password-confirmation-to-delete-account
Aug 30, 2026
Merged

thermcampos merged 3 commits into
mainfrom
feat/66-require-password-confirmation-to-delete-account

Conversation

@thermcampos

Copy link
Copy Markdown
Owner

Closes #66.

Why

Deleting an account previously took a single click on an inline confirmation. This adds a password gate: after clicking "Delete all my data", the user must type their current password before anything is deleted.

What changed

  • Endpoint: POST /rest/user-sessions/delete-account with a JSON body (DeleteAccountRequest, @NotBlank password), replacing the bodyless DELETE.
  • Verification before deletion: AuthService.verifyCurrentPassword reuses checkLoginAttemptLimit (3 failures / 3 minutes) and records a UserPwdLimitEntity on mismatch, then throws InvalidCredentialsException. On success the rate-limit rows are wiped with the account as before.
  • Bug fix: verification now runs in the controller before the delete transaction opens. Previously the attempt save ran inside the delete's @Transactional and was rolled back on failure, so the rate limit never engaged. Each downstream deletion already runs in its own transaction, so the service method no longer needs one.
  • Frontend: the confirmation dialog has a password field with show/hide toggle and an inline error region (data-testid="delete-account-error"). Wrong password shows the error in place, clears the field, and keeps the dialog open; success signs out and clears local storage. The dialog resets state when dismissed and disables the confirm button while submitting or when the field is empty.
  • i18n: delete-dialog description updated in English, Spanish, Portuguese, and Russian.
  • Tests: integration tests cover correct-password (all data wiped, rate-limit rows gone), wrong-password (nothing deleted, attempt recorded), and max-attempts lockout, plus a dedicated non-transactional test proving the attempt survives the rollback. Controller tests cover POST happy path, missing-password 400, and unauthorized 401. Frontend tests cover happy path, inline failure, dialog close resetting state, and the disabled confirm button.

Both quality gates pass: tools/check-backend.sh (checkstyle, compile, unit + integration, JaCoCo) and tools/check-frontend.sh (lint, build, 118 tests).

💘 Generated with Crush

The delete-account endpoint is now POST /rest/user-sessions/delete-account
with a JSON body carrying the current password, replacing the bodyless
DELETE. The password is verified before any deletion work begins; on
mismatch the request fails, nothing is deleted, and the attempt is
recorded against the existing login rate limit (3 failures in 3 minutes).

Verification happens before the delete transaction opens (in the
controller) so a wrong password does not open a transaction whose rollback
would wipe the recorded attempt. Each downstream deletion already runs in
its own transaction, so the service method no longer needs one.

The confirmation dialog gains a password field with show/hide toggle and
an inline error region: wrong password shows the error in place, clears
the field, and keeps the dialog open; success signs the user out and
clears local storage. The dialog also resets its state when dismissed and
disables the confirm button while submitting or when the field is empty.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thermcampos thermcampos linked an issue Aug 29, 2026 that may be closed by this pull request
6 tasks
@thermcampos
thermcampos merged commit e0becc3 into main Aug 30, 2026
2 checks passed
@thermcampos
thermcampos deleted the feat/66-require-password-confirmation-to-delete-account branch August 30, 2026 22:16
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.

Require password confirmation to delete account

1 participant