DevPath

Fix an ownership check that lets one user read another user's record

Mid · debugging · 20 min · runtime php-cli

Brief

The handler below returns any record by id. Rewrite canRead(array $record, int $userId): bool and describe the change: a user may read a record only when record['owner_id'] equals their id.

3 progressive hints are available in the editor.

Public checks

  • owner may read — expected: true
  • other user may not read — expected: false