statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.71k stars 508 forks source link

Special "author" permissions: visibility and "updated_by" not behaving as expected #8433

Closed schwemmer closed 8 months ago

schwemmer commented 1 year ago

Bug description

I have a Collection named "Publications" and a role "Publication Editor" who can only create, edit and delete their own "Publications". For this, I added a field "Relationship > Users" and called the handle "author" and the label "Created by".

How to reproduce

Logs

No response

Environment

Environment
Laravel Version: 9.52.10
PHP Version: 8.2.7
Composer Version: 2.5.8
Environment: local
Debug Mode: ENABLED
URL: localhost:8003
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 3
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.10.1 PRO

Statamic Addons
aryehraber/statamic-impersonator: 2.6.0
jacksleight/statamic-bard-texstyle: 3.1.3
textandbytes/cp-assets: dev-main

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

runtime (new)

Additional details

No response

duncanmcclean commented 8 months ago

Statamic doesn't automatically set the "Author" field when a super user creates/edits entries. This is intentional so when a super user edits another author's entry, they don't take over the entry from the original author.

However, super users are able to edit the "Author" field so they could assign themselves as the author of the entry.

^ Although, make sure the "Visibility" of the author field is set to "Visible". Statamic will handle adjusting the visibility based on user permissions.

If you don't need any of the author permissions magic, change the handle of the users field to something else and set the value in a listener based on the currently authenticated user.

jesseleite commented 8 months ago

PS. To add to that, you can read more about how Statamic handles the reserved author field here:

schwemmer commented 8 months ago

Thank you for your explanations.