Save creating user in ContentRepository

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.

you could look into node type preprocessor and into node security privileges

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'

in your Package.php (see this for reference: Package Management — Flow Framework dev-master documentation)

add this connector:

$dispatcher = $bootstrap->getSignalSlotDispatcher();
$dispatcher->connect(Node::class, 'beforeNodeCreate', function (NodeInterface $node) use ($bootstrap) {
    if ($node->getNodeType()->isOfType('A.B:Document.D') === false) {
        return;
    }
    $userService = $bootstrap->getObjectManager()->get(UserService::class);
    $node->setProperty('creator', $userService->getCurrentUser());
});

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')}

so you would need to extend this:

and insert it into your extended neos-development-collection/EditNodePrivilege.php at f8e64887233eda2e4afd1a1a7327429b7694dd22 · neos/neos-development-collection · GitHub
as the property: protected $nodeContextClassName = YourExtendedNodePrivilegeContext::class;

Thank you for your fast and extensive input!

I will need to check how I can implement your suggestions and will reply in more detail later :slight_smile: