diff --git a/protected/humhub/modules/user/models/User.php b/protected/humhub/modules/user/models/User.php index 35d4d34b9d..0759ccbf25 100644 --- a/protected/humhub/modules/user/models/User.php +++ b/protected/humhub/modules/user/models/User.php @@ -170,7 +170,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se return $this->isEmailRequired(); }], [['guid'], 'unique'], - [['username'], 'validateForbiddenUsername', 'on' => [self::SCENARIO_REGISTRATION]], + [['username'], 'validateForbiddenUsername', 'on' => [self::SCENARIO_REGISTRATION]], ]; } @@ -199,7 +199,10 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se */ public function validateForbiddenUsername($attribute, $params) { - if (in_array(strtolower($this->$attribute), Yii::$app->controller->module->forbiddenUsernames)){ + /** @var Module $module */ + $module = Yii::$app->getModule('user'); + + if (in_array(strtolower($this->$attribute), $module->forbiddenUsernames)) { $this->addError($attribute, Yii::t('UserModule.account', 'You cannot use this username.')); } }