I would like to get the Role of the user logged in.
I'm trying to use the \vendor\magento\module-user\Model\User.php
class, but all results give me null or empty.
I'm trying to use \vendor\magento\module-authorization\Model\Role.php
, but the same happens, all empty.
I have achieved getting the userName of the user logged in, which might help, with this class: \vendor\magento\module-backend\Model\Auth\Session.php
I have checked the database, and in the authoritzation_role
I have:
Where the parent_id
refers to the 3 roles I have created:
What am I doing wrong here? Am I calling the right classes? Is there a better way to do it?