Skip to content

Add endpoint for creating a policy acceptance for a specific user#1197

Merged
dati18 merged 6 commits into
mainfrom
policy-accept-user
Jul 16, 2026
Merged

Add endpoint for creating a policy acceptance for a specific user#1197
dati18 merged 6 commits into
mainfrom
policy-accept-user

Conversation

@dati18

@dati18 dati18 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add authenticated endpoint to record policy acceptances for the current user, with strict validation and all-or-nothing behavior for invalid policy IDs.

Behavior

  • Uses authenticated user from session context (no user_id in payload)
  • Ignores already-accepted policies (idempotent writes via firstOrCreate)
  • If any provided policy ID does not exist, returns 400 with missing_policy_ids
  • No acceptances are created when invalid policy IDs are present
  • Returns 422 for invalid payload (missing policy_ids, non-array, non-integer items)

Bug: T431674

@dati18
dati18 force-pushed the policy-accept-user branch from 181bc2d to 0ca4ecc Compare July 14, 2026 11:04

@tarrow tarrow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only blocker from my side is around confirming we don't update accepted_at time on each request.

Comment thread tests/Routes/PolicyAcceptanceControllerTest.php
Comment thread tests/Routes/PolicyAcceptanceControllerTest.php
Comment thread app/Http/Controllers/PolicyAcceptanceController.php
Comment thread tests/Routes/PolicyAcceptanceControllerTest.php
Comment thread app/Http/Controllers/PolicyAcceptanceController.php
Comment thread tests/Routes/PolicyAcceptanceControllerTest.php
@dati18
dati18 requested a review from tarrow July 14, 2026 16:01
Comment thread routes/api.php Outdated

@tarrow tarrow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the final change. I'm now happy with this.

@dati18
dati18 force-pushed the policy-accept-user branch from 160d88e to 80bc9ee Compare July 16, 2026 14:01
@dati18
dati18 merged commit 8ce087c into main Jul 16, 2026
4 checks passed
@dati18
dati18 deleted the policy-accept-user branch July 16, 2026 14:05
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.

2 participants