2
votes

In my Yii2 project previously I had worked on rbac, set it up as in the yii2 doc click here. Now I worked on different modules and I am back on rbac. Initially set it up with just sysadmin and staff. Now I want to add a new role along with the two previous roles. Which I did it auth_item table and assigned the user_id in the auth_assignmnet table to the new role created.

In my controller added the role name for which actions he can access. But still throws Forbidden Exception. Tried different things but unable to work on it..

Any solution for this?

1
RBAC might be cached. Have you tried to flush cache?Bizley
When I run php yii cache it just shows ** * cache (yii\caching\FileCache)** found...Mohan Prasad
Are you sure this is the message given? Anyway, just flush it then.Bizley
I couldn't get that working..but when to run time and cleared the rbac.in log file and its up and running now..brilliant thanks a million was stuck with this for a very long timeMohan Prasad
Ok, let me add proper answer so other can find help in similar case.Bizley

1 Answers

3
votes

First of all, you should modify RBAC structure using the provided authManager methods.

After adding new RBAC items manually in database or files you need to make sure cache is not keeping the old data.

Flush cache manually or call console method like

yii cache/flush-all