Problem/Motivation

The public endpoint /api/qr-code/{uuid} checks whether a QR code exists and has expired, but does not check its status field. Consequently, disabled codes continue redirecting visitors to their configured destinations.

This also affects account cancellation using user_cancel_block_unpublish: the cancellation hook disables the user’s QR codes, but those codes remain usable through the public endpoint.

Steps to reproduce

1. Create an enabled QR code with a valid destination and no expiration.
2. Visit its public scan URL as an anonymous visitor and confirm that it redirects.
3. Edit the QR code, clear its Enabled status, and save.
4. Visit the same scan URL again.

Actual result

The disabled QR code still redirects to its destination.

Expected result

Disabled QR codes return HTTP 404 without redirecting. Enabled, unexpired codes remain accessible to anonymous visitors. Enabled but expired codes continue returning HTTP 410, and unknown UUIDs return HTTP 404.

Proposed resolution

Update QRRestResource::get() to check the entity’s status immediately after UUID lookup, before checking expiration or constructing the destination. Use translated public error messages without exposing administrative details.

Preserve anonymous scanning without requiring administrative entity-view permissions. Review the resource’s unused access() method and remove it if confirmed unused by the REST route pipeline.

Regression coverage

Extend QRRestResourceFunctionalTest.php to cover:

- Disabled codes, including disabled codes that are also expired.
- Disabling and re-enabling after a successful scan.
- Codes disabled through account cancellation.
- Anonymous access to enabled, unexpired codes.
- Existing 404 and 410 behavior.

Assert the redirect status and Location header directly instead of relying on the final HTTP 200 after following redirects.

CommentFileSizeAuthor
#3 3632912-disabled-qr-code-scans.patch8.95 KBc2h2o5
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

c2h2o5 created an issue. See original summary.

c2h2o5’s picture

StatusFileSize
new8.95 KB

Here the patch as file

  • m.evans committed aeec54b5 on 2.x authored by c2h2o5
    fix: #3632912 Disabled QR codes continue to redirect through the public...
m.evans’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

m.evans’s picture

Status: Fixed » Closed (fixed)