2

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?

5
  • RBAC might be cached. Have you tried to flush cache? Commented Dec 9, 2016 at 9:40
  • When I run php yii cache it just shows ** * cache (yii\caching\FileCache)** found... Commented Dec 9, 2016 at 9:41
  • Are you sure this is the message given? Anyway, just flush it then. Commented Dec 9, 2016 at 9:51
  • 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 time Commented Dec 9, 2016 at 10:11
  • Ok, let me add proper answer so other can find help in similar case. Commented Dec 9, 2016 at 10:45

1 Answer 1

3

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 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.