Skip to content

Commit

Permalink
Merge pull request #2 from janki1/feature/user-roles
Browse files Browse the repository at this point in the history
Feature/user roles
  • Loading branch information
janki1 authored Aug 9, 2022
2 parents e853efc + b19631d commit 7e68e35
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Module configure
---
### Property

* 'role' array|null Allowed user roles to access this module. Default only logged user. See https://www.yiiframework.com/doc/api/2.0/yii-filters-accessrule#$roles-detail
* 'roles' array|null Allowed user roles to access this module. Default only logged user. See https://www.yiiframework.com/doc/api/2.0/yii-filters-accessrule#$roles-detail
* `uploadFolder` the directory where stored files. Default is `@app/web/uploads/images`. If folder not existed, roxy will auto-create it.
* `uploadUrl` the url which can get folder link. Default is `/uploads/images`. If you are using `yii2-advanced` should include scheme (`http://frontend.domain.com/uploads/images`).
* `defaultView` display type. Default is `thumb`
Expand Down
9 changes: 5 additions & 4 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
/**
* {@inheritDoc}
*/
class Module extends BaseModule {
class Module extends BaseModule
{

/**
* Header string
Expand All @@ -28,10 +29,10 @@ class Module extends BaseModule {
public $title = 'File Manager';

/**
* User role see https://www.yiiframework.com/doc/api/2.0/yii-filters-accessrule#$roles-detail
* @var string
* User roles see https://www.yiiframework.com/doc/api/2.0/yii-filters-accessrule#$roles-detail
* @var array
*/
public $role = ['@'];
public $roles = ['@'];

/**
* @var string default folder which will be used to upload resource
Expand Down
1 change: 1 addition & 0 deletions src/controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function behaviors(): array
'class' => AccessControl::class,
'rules' => [
[
'allow' => true,
'roles' => $this->module->role
]
]
Expand Down
1 change: 1 addition & 0 deletions src/controllers/ManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function behaviors(): array
'class' => AccessControl::class,
'rules' => [
[
'allow' => true,
'roles' => $this->module->role
]
]
Expand Down

0 comments on commit 7e68e35

Please sign in to comment.