Search code examples
neoscms

How can I debug what role a user is logged in as?


How can I debug what role a user is logged in as?

I'm making a plugin in Neos with front-end users, and want to limit access to certain actions using view-helpers:

<f:security.ifHasRole role="Example.Something:User">

Solution

  • In controller, write:

    /**
     * @var \TYPO3\Flow\Security\Context
     * @Flow\Inject
     */
    protected $securityContext;
    
    // In controller action
    $this->securityContext->getAccount() 
    

    And in Fluid view:

    <f:debug>{account.roles}</f:debug>