Hi,
I want to save the user who creates a node in some form in the content repository.
My class looks something like this:
'A.B:Document.D'
superTypes:
'Neos.Neos:Document': true
properties:
creator:
type: string
defaultValue: 'here should the user be saved'
However I can’t find any way to access the user in the ContentRepository. I tried playing around with ClientEval:node. …’, but couldn’t find the appropriate property or it only showed as simple string when I called the property with Neos.Fusion:Debug in my Fusion-file.
I also tried writing an Eel Helper accessing the UserService, but this only seems to work with Fusion and not in the Content Repository.
Another way I thought about, but couldn’t implement was using the contextpath/workspaceName and abbreviating it.
Is there any way this is possible, so that I can save the creator of a node?
The final goal of this approach is, that users can only edit nodes they created themselves, so if there is a shortcut to that or best practices to achieve that, that would also be great.
the mentioned NodeTypePostprocessorInterface is only to mutate the configuration of the node types …
but you could connect to this Flow Signal:
i would start something like this and var_dump the node to see if this works ^^
you probably need to change the nodeType declaration:
properties:
creator:
type: Neos\Neos\Domain\Model\User
ui:
inspector:
hidden: true
# a dummy editor, so the ui doenst complain its not there
editor: 'Neos.Neos/Inspector/Editors/BooleanEditor'
concerning the Node Privileges there exists a ready to use Editnodeprivilege
but the used NodePrivilegeContext for the eel expression doesnt support currently a propertyMatches function like: ${propertyMatches('creator', 'context.userService.currentUser')}