fix(roles): check the right to save before the revision #100

Merged
sharang merged 1 commits from fix/role-dataset-permission-first into main 2026-10-28 12:00:46 +00:00
Owner

A save of the role dataset now checks who may save before it compares expected_revision.

Before: someone without the right to save (B7: management or document owner; Q3: CXO until management exists) who sent a stale revision got 409 revision_conflict. The portal shows that as "Inzwischen hat jemand anderes etwas geändert". After a reload they got 403 not_permitted. This was seen in the R1 S0 stage check: an IT admin on an outdated page.

After:

  • That person gets 403 not_permitted straight away.
  • Someone who may save still gets 409 on a stale revision.
  • The CXO first-entry rule (bootstrap_only) is still checked in Prepare, after the revision check, because it looks at what the save changes.

Changes:

  • roles.MayWrite(current, writer): the who-may-save part of Prepare, which now calls it.
  • server/role_dataset.go: calls MayWrite before the revision comparison.
  • Test: staff and a late CXO, both with a stale revision, get not_permitted.

No migration, no API shape change, no catalogue change. Checks: go vet, go test ./... pass locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf

A save of the role dataset now checks who may save before it compares `expected_revision`. **Before:** someone without the right to save (B7: management or document owner; Q3: CXO until management exists) who sent a stale revision got `409 revision_conflict`. The portal shows that as "Inzwischen hat jemand anderes etwas geändert". After a reload they got `403 not_permitted`. This was seen in the R1 S0 stage check: an IT admin on an outdated page. **After:** - That person gets `403 not_permitted` straight away. - Someone who may save still gets `409` on a stale revision. - The CXO first-entry rule (`bootstrap_only`) is still checked in `Prepare`, after the revision check, because it looks at what the save changes. Changes: - `roles.MayWrite(current, writer)`: the who-may-save part of `Prepare`, which now calls it. - `server/role_dataset.go`: calls `MayWrite` before the revision comparison. - Test: staff and a late CXO, both with a stale revision, get `not_permitted`. No migration, no API shape change, no catalogue change. Checks: `go vet`, `go test ./...` pass locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
sharang added 1 commit 2026-10-28 11:35:37 +00:00
fix(roles): check the right to save before the revision
ci / shared (pull_request) Successful in 11s
ci / test (pull_request) Successful in 24m32s
ci / image (pull_request) Skipped
1e07f21505
A person who may not save the role dataset and sent a stale revision got
409 revision_conflict ("someone else changed it") instead of 403
not_permitted. MayWrite now runs before the revision check; Prepare uses
it too. Found in the R1 S0 stage check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
sharang merged commit cb173104b6 into main 2026-10-28 12:00:46 +00:00
sharang deleted branch fix/role-dataset-permission-first 2026-10-28 12:00:47 +00:00
Sign in to join this conversation.