Fixed User module access

This commit is contained in:
Lucas Bartholemy 2022-02-09 15:15:19 +01:00
parent f8b8d912af
commit 3bb581f03c

View File

@ -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.'));
}
}