From 3bb581f03ccdaefe52667389df70c8c077fb6311 Mon Sep 17 00:00:00 2001 From: Lucas Bartholemy Date: Wed, 9 Feb 2022 15:15:19 +0100 Subject: [PATCH] Fixed User module access --- protected/humhub/modules/user/models/User.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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.')); } }