Skip to content

Commit dcb7b15

Browse files
committed
registration can be enabled via config
1 parent 1a644a2 commit dcb7b15

4 files changed

Lines changed: 17 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Configuration
5353
'user-management' => [
5454
'class' => 'webvimark\modules\UserManagement\UserManagementModule',
5555

56+
// 'enableRegistration' => true,
57+
5658
// Here you can set your handler to change layout for any controller or action
5759
// Tip: you can use this event in any module
5860
'on beforeAction'=>function(yii\base\ActionEvent $event) {

UserManagementModule.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ class UserManagementModule extends \yii\base\Module
7777
*/
7878
public $confirmationTokenExpire = 3600; // 1 hour
7979

80+
/**
81+
* Registration can be enabled either by this option or by adding '/user-management/auth/registration' route
82+
* to guest permissions
83+
84+
* @var bool
85+
*/
86+
public $enableRegistration = false;
87+
8088
/**
8189
* Roles that will be assigned to user registered via user-management/auth/registration
8290
*

models/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public function beforeSave($insert)
375375
}
376376

377377
// Don't let non-superadmin edit superadmin
378-
if ( !Yii::$app->user->isSuperadmin AND $this->oldAttributes['superadmin'] == 1 )
378+
if ( isset($this->oldAttributes['superadmin']) && !Yii::$app->user->isSuperadmin && $this->oldAttributes['superadmin'] == 1 )
379379
{
380380
return false;
381381
}

models/rbacDB/Route.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ public static function isFreeAccess($route, $action = null)
205205
return true;
206206
}
207207

208+
// Registration can be enabled either by this option or by adding '/user-management/auth/registration' route to guest permissions
209+
if ( $route == '/user-management/auth/registration' && Yii::$app->getModule('user-management')->enableRegistration === true )
210+
{
211+
return true;
212+
}
213+
208214
if ( static::isInCommonPermission($route) )
209215
{
210216
return true;

0 commit comments

Comments
 (0)