1

So I have an action which I need multiple permissions to have access to.

(for example manageUsers (admin) and manageCompanyUsers (company manager))

access behaviour in controller has rule like:

'allow' => true,
'actions' => ['index'],
'roles' => [
   'manageUsers',
   'manageCompanyUsers'
],
'roleParams' => ['company' => 'some id']

1) how do I pass different params for different roles in it? (with this code it passes company to manageCompanyUsers anyway)

2) how can I make sure that if manageUsers is a child of manageCompanyUsers and user has manageUsers assigned directly to not trigger manageCompanyUsers rules (it triggers now)

Herokiller
  • 2,560
  • 5
  • 29
  • 48

1 Answers1

0

Make several rules with different params and roles applied to each:

[ //rule1
  'allow' => true,
  'actions' => ['index'],
  'roles' => [
     'manageUsers',
  ],
  'roleParams' => ['company' => 'some id']
],
[ //rule2
  'allow' => true,
  'actions' => ['index'],
  'roles' => [
     'manageCompanyUsers',
  ],
  'roleParams' => ['some' => 'other id']
],
yrv16
  • 1,985
  • 1
  • 9
  • 18
galymzhan
  • 5,374
  • 2
  • 27
  • 45