Move Organization affiliation-date lock off Current.user

Open
#2,833 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
ruby

Research direction

Read CLAUDE.md’s “Authorization lives in policies” rule, then trace Organization#affiliation_dates_locked and the controller and admin service callers that save organizations. Inventory callers that currently rely on Current.user to bypass the lock, including dedupe merges; determine how each would supply the proposed flag. Done means the callers are accounted for so moving the permission decision into a policy does not break their saves.

Written by the indexing model from the issue text.

Description

blocked

🤖 From Claude: Organization#affiliation_dates_locked is skipped for admins by reading Current.user&.super_user? inside the model. Models shouldn't make permission decisions (see the "Authorization lives in policies" rule in CLAUDE.md, added in #2831).

Proposed fix

  • The controller asks a policy rule (e.g. OrganizationPolicy#edit_affiliation_dates?).
  • It hands the model a flag, the way story ideas set organization_required.

Why blocked

  • Admin-run services that save organizations (e.g. dedupe merges) currently bypass the lock through Current.user.
  • With a flag, each of those callers has to set it, or its saves start failing validation.
  • They need to be inventoried first.
Dominant language
Ruby
Stars
15
Forks
28
Avg merge
14h 29m
Merged PRs (30d)
292

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rubyforgood/awbw

All issues in rubyforgood/awbw

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.