Does Anyone Have A Working Example Of Rbac?

Note that if I’m right then the official doc should be fixed: Basic information about RBAC

Yah im now learning the hard way that the official doc is pretty out of date with what should be done to implement this. So much source code to read to figure out how this works! Im just going to abandon RBAC altogether now lol.

Does anyone have a working example of YII2 RBAC PhpManager with a working update own post??

(With the Yii advanced template)

Because I want thousands of special users to be able to update own posts and images.

I don’t think it is that hard but after googling for weeks I only get lots of information not to use the DbManager

because it will create lots of extra db calls.

And not how to theoraticly set up RBAC to update own posts…

The best working example with RBAC is http://www.yiiframework.com/extension/yii2-improved-advanced-template/

And I’ve asked the developer to ad a simple posts table to update own posts…

Thanks in advance!!

1 Like

You can place the check in the behaviors() function to easily control access to actions but you can also use it 1) in views to show and hide things based on permissions (you should use permissions rather than roles) and also you might need finer control over permissions such as if user has permission X then a post is added with a property set to something, otherwise it is not set. That kind of fine grained control can live in the action function itself.

I made a video about rbac in case anyone’s interested. The concept takes longer to understand than it does to code it.

Ha…ha…

Looks like I will use clasic one instead. Need more time to learn RBAC but still can’t find any working example with large user and certain user group beside “admin” username.

If anyone have working example please give it here… :rolleyes: