Skip to content

CLI: add 'jss account delete' + refactor 'passwd' (#292)#293

Merged
melvincarvalho merged 1 commit into
JavaScriptSolidServer:gh-pagesfrom
melvincarvalho:issue-292-account-delete-cli
Apr 22, 2026
Merged

CLI: add 'jss account delete' + refactor 'passwd' (#292)#293
melvincarvalho merged 1 commit into
JavaScriptSolidServer:gh-pagesfrom
melvincarvalho:issue-292-account-delete-cli

Conversation

@melvincarvalho

Copy link
Copy Markdown
Contributor

Fixes #292.

Two related changes

1. `jss account delete ` (new)

Wraps the existing `accounts.deleteAccount(id)` (which already prunes the username/email/webId indexes and removes the account JSON) behind a CLI surface. Operators no longer need to hand-edit JSON to drop an account.

```
jss account delete melvin # confirm prompt, account record only
jss account delete melvin --yes # skip prompt
jss account delete melvin --yes --purge # also remove /melvin/
```

`--purge` is opt-in because the two destructive levels are genuinely different:

  • Account record removal revokes identity (recoverable — the user could re-register).
  • Pod data removal is irreversible.

Default behaviour preserves pod data so you can re-bind a different account later or back it up before deletion. `--purge` is for the clean-slate case (which my smoke test confirmed lets you re-register the same username afterward).

2. `jss passwd` refactored to use the wrapper

Same external behaviour, but the body now calls `findByUsername` + `updatePassword` from `src/idp/accounts.js` instead of duplicating the index lookup and bcrypt hashing inline. ~40 fewer lines, single source of truth for the hashing parameters (`SALT_ROUNDS` lives in `accounts.js`; `passwd` no longer hard-codes `10`).

This brings `passwd` into the same shape as `invite` / `quota` / the new `account delete` — every CLI command consumes its corresponding `src/` module instead of re-implementing internals.

Files

Single file: `bin/jss.js` (+58, -31).

Test plan

  • Existing suite: 398/398 pass.
  • Manual smoke test against `--idp` server:
    • register charlie → `jss account delete charlie --yes` → account JSON gone, indexes pruned, pod dir preserved.
    • register charlie again with same name → still blocked (pod dir exists, JSS refuses duplicate).
    • register charlie → `jss account delete charlie --yes --purge` → account + pod dir both gone.
    • register charlie one more time → succeeds (clean slate).
    • register bob → `jss passwd bob --password ...` → password updated via wrapper.
  • No unit tests added — the CLI isn't covered by any existing test suite. Worth a separate `test/cli.test.js` later but explicitly out of scope here.

Non-goals

  • Account list / info / disable subcommands — tracked separately.
  • HTTP `DELETE /idp/account` self-service endpoint — needs an auth-story design (admin vs self), separate issue.
  • Token / session revocation for the deleted account — tokens expire naturally; thorough revocation is its own concern.

…avaScriptSolidServer#292)

Two related changes:

1. New `jss account delete <username>` subcommand. Calls
   accounts.deleteAccount() (the existing internal API) which already
   prunes the username/email/webId indexes and removes the account
   JSON. Adds a --yes flag (skip confirm prompt) and an opt-in
   --purge flag (also remove pod data at <dataRoot>/<username>/).

   Without --purge: account record removed, pod data preserved.
   With --purge:    fully clean, username can be re-registered.

   The --purge flag is opt-in because account deletion revokes
   identity (recoverable), but pod data removal is destructive
   (irreversible). Operators choose the level of cleanup.

2. Refactor `jss passwd <username>` to use the same accounts.js
   wrappers (findByUsername + updatePassword) instead of duplicating
   the index lookup and bcrypt hashing inline. Same external
   behaviour, ~40 fewer lines, one source of truth for the hashing
   parameters.

Manual smoke test against a fresh --idp server: register / delete /
re-register works; --purge frees the username; plain delete preserves
pod data; passwd still works post-refactor. Existing 398-test suite
passes (CLI commands aren't unit-tested anywhere in the repo today).

Fixes JavaScriptSolidServer#292
@melvincarvalho
melvincarvalho requested a review from Copilot April 22, 2026 04:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@melvincarvalho
melvincarvalho requested a review from Copilot April 22, 2026 04:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

CLI: add 'jss account delete' (and refactor 'passwd' to use the same wrapper)

2 participants