https://github.com/luyadev/luya-module-frontendgroup
Provides Group Permissions for Users in the CMS.
https://github.com/luyadev/luya-module-frontendgroup
Last synced: 4 months ago
JSON representation
Provides Group Permissions for Users in the CMS.
- Host: GitHub
- URL: https://github.com/luyadev/luya-module-frontendgroup
- Owner: luyadev
- License: mit
- Created: 2016-02-01T15:57:16.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2021-10-05T09:00:22.000Z (about 4 years ago)
- Last Synced: 2025-07-23T05:14:42.718Z (5 months ago)
- Language: PHP
- Homepage: https://luya.io
- Size: 19.5 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Frontend User Group Module
[](https://luya.io)
[](https://packagist.org/packages/luyadev/luya-module-frontendgroup)
[](https://packagist.org/packages/luyadev/luya-module-frontendgroup)
[](https://slack.luya.io/)
The main purpose of this module to provide the ability to allow cms pages for specific user groups. This can also be only one group with one users or different users in the same group or different groups with different users.
## Installation
For the installation of modules Composer is required
```sh
composer require luyadev/luya-module-frontendgroup
```
### Configuration
After adding to your composer json you have to include the frontendgroup module into your Yii/LUYA config of your project and bootstrap the Module (otherwhise it can not catch the menu before item event).
```php
'modules' => [
// ...
'frontendgroup' => [
'class' => 'luya\frontendgroup\Module',
'frontendUsers' => [
'user1', 'user2', 'user3',
],
'frontendGroups' => [
'groupA', 'groupB',
],
],
],
'bootstrap' => [
// ...
'frontendgroup',
],
'components' => [
// ...
'user1' => [
'class' => 'luya\web\GroupUser',
'identityClass' => 'app\models\User1Class',
],
'user2' => [
'class' => 'luya\web\GroupUser',
'identityClass' => 'app\models\User2Class',
],
'user3' => [
'class' => 'luya\web\GroupUser',
'identityClass' => 'app\models\User3Class',
],
]
```
The config above shows defines your configuration:
+ In the module `frontendgroup` you have to define the different users which are allowed in your setup by `frontendUsers`. And you have to defined the available groups by using `frontendGroups`.
+ The mentioned `frontendUsers` in the module must exists als component with the base class `luya\web\GroupUser` (this is a wrapper of yii\web\User).
The frontend users must follow the `GroupUserIdentityInterface`:
```php
// GroupUserIdentityInterface implentation
class User1 extends \yii\db\ActiveRecord implements GroupUserIdentityInterface
{
// ...
public function authGroups()
{
return ['groupA', 'groupB'];
}
// ...
}
```
The the above user class of `User1` is now allowed to access all pages which are defined for `groupA` and `groupB`.
### Initialization
After successfully installation and configuration run the migrate, import and setup command to initialize the module in your project.
1.) Migrate your database.
```sh
./vendor/bin/luya migrate
```
2.) Import the module and migrations into your LUYA project.
```sh
./vendor/bin/luya import
```