In my custom component, I'd like to be able to restrict specific views to only certain usergroups. If I create a menu item for one of my views, that's pretty easy to do: I just select the access level for that menu item and I'm done.
Now, the problem comes if someone tries to access directly an URL with option=com_mycomponent, or any of the internal redirections of my component goes to a page with no assigned Itemid... in that case, it's the component itself the one that needs to check the user group and determine if it's able to view that page... how can I restrict that in my code? Just a simple hardcoded check for user's usergroup? Or there's a "standard" way for doing it?
I've been checking documentation, and have found this:
but that's for what user can do, not for what user can see. I've also found this forum thread:
the code at the beginning is quite old, but at the end it's recommended to use this:
How should I proceed for that? Should I define assets for main object generated by my view so I can test access for it with JUser?
Thanks in advance.