Skip to content

user: moving a user moves its permission rows - #92

Merged
msimerson merged 3 commits into
NicTool:mainfrom
aberoham:user-move-permission
Oct 16, 2026
Merged

msimerson merged 3 commits into
NicTool:mainfrom
aberoham:user-move-permission

Conversation

@aberoham

Copy link
Copy Markdown
Contributor

Moving a user left their explicit permission row in the old group, so Permission.get({ uid }) reported a group they had left. A move now carries the user's permission rows with it, on mysql in the same transaction as the nt_user update.

Going explicit again after a revoke used to hit a create conflict on mysql and revive the revoked grants on json and toml. Every store now starts the user fresh.

A user's explicit permission row stayed in the old group after a move,
so Permission.get({ uid }) reported a group the user had left. On mysql
the nt_user and nt_perm updates share a transaction and every one of
the user's rows moves, deleted ones too. The file stores move the
inline permission with the user.

An inheritance change in the same PUT runs in that transaction under a
lock on the user's row, so a failure rolls back the move as well.
Going explicit after a revoke gives the user fresh permissions on every
store instead of a create conflict or the revoked grants.

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.

🟡 Changes recommended

Resetting file-backed permissions can duplicate permission IDs and cause later operations to target another user.

1 open finding
What changed in this PR

Keeps user permissions aligned with group moves and resets revoked permissions when users switch back to explicit permissions.

Changes:

  • Moves MySQL permission rows transactionally with their user.
  • Updates file-backed permission groups and resets revoked grants.
  • Adds regression tests and a changelog entry.
File Description
lib/​user/​test/​mysql.js Tests rollback, missing users, and permission resets.
lib/​user/​test/​index.js Tests explicit permissions following user moves.
lib/​user/​store/​mysql.js Makes moves and permission changes transactional.
lib/​user/​store/​file.js Updates permission groups and resets revoked permissions.
lib/​store/​file.test.js Tests permission resets for JSON and TOML.
CHANGELOG.md Documents the user-move fix.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/user/store/file.js Outdated

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.

🟢 Approval recommended

Static review found no blocking issues, and regression tests cover the principal changed paths; tests were not run.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@msimerson
msimerson merged commit d5cc953 into NicTool:main Oct 16, 2026
10 checks passed
@aberoham
aberoham deleted the user-move-permission branch October 16, 2026 22:20
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.

3 participants