mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Don't validate user language on approve (#5865)
* Don't validate user language on approve * Fix tests with base URL checking * Revert "Fix tests with base URL checking" This reverts commit ef9141643ad3ee71dcda570d6513b0bcb849a9be. * Check for allowed language on registration and account updating
This commit is contained in:
parent
40fe9cfee0
commit
4309b4b4ed
@ -5,6 +5,7 @@ HumHub Changelog
|
||||
-------------------
|
||||
- Fix #5851: Admin User Settings cannot saved
|
||||
- Fix #5856: Fix SMTPS Config Migration
|
||||
- Fix #5854: Don't validate user language on approve
|
||||
|
||||
|
||||
1.12.1 (August 15, 2022)
|
||||
|
@ -192,6 +192,26 @@ class I18N extends BaseI18N
|
||||
return $availableLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the provided or browser language is allowed in system, otherwise return default language
|
||||
*
|
||||
* @since 1.12.2
|
||||
* @param string|null $language NULL - to get a language from browser
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAllowedLanguage(?string $language = null): ?string
|
||||
{
|
||||
if (empty($language)) {
|
||||
$language = Yii::$app->language;
|
||||
}
|
||||
|
||||
if (array_key_exists($language, $this->getAllowedLanguages())) {
|
||||
return $language;
|
||||
}
|
||||
|
||||
return Yii::$app->settings->get('defaultLanguage');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
@ -157,14 +157,9 @@ class ApproveUserForm extends \yii\base\Model
|
||||
}
|
||||
|
||||
$this->user->status = User::STATUS_ENABLED;
|
||||
$this->user->setScenario(User::SCENARIO_APPROVE);
|
||||
|
||||
if ($this->validate() &&
|
||||
$this->user->save() &&
|
||||
$this->send()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return $this->user->save() && $this->send();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,10 +118,7 @@ class AccountController extends BaseAccountController
|
||||
$user = Yii::$app->user->getIdentity();
|
||||
|
||||
$model = new \humhub\modules\user\models\forms\AccountSettings();
|
||||
$model->language = $user->language;
|
||||
if ($model->language == "") {
|
||||
$model->language = Yii::$app->settings->get('defaultLanguage');
|
||||
}
|
||||
$model->language = Yii::$app->i18n->getAllowedLanguage($user->language);
|
||||
$model->timeZone = $user->time_zone;
|
||||
if (empty($model->timeZone)) {
|
||||
$model->timeZone = Yii::$app->settings->get('defaultTimeZone');
|
||||
|
@ -99,6 +99,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
|
||||
const SCENARIO_REGISTRATION = 'registration';
|
||||
const SCENARIO_REGISTRATION_EMAIL = 'registration_email';
|
||||
const SCENARIO_EDIT_ACCOUNT_SETTINGS = 'editAccountSettings';
|
||||
const SCENARIO_APPROVE = 'approve';
|
||||
|
||||
/**
|
||||
* @event Event an event that is triggered when the user visibility is checked via [[isVisible()]].
|
||||
@ -165,7 +166,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
|
||||
[['time_zone'], 'validateTimeZone'],
|
||||
[['auth_mode'], 'string', 'max' => 10],
|
||||
[['language'], 'string', 'max' => 5],
|
||||
['language', 'in', 'range' => array_keys(Yii::$app->i18n->getAllowedLanguages())],
|
||||
['language', 'in', 'range' => array_keys(Yii::$app->i18n->getAllowedLanguages()), 'except' => self::SCENARIO_APPROVE],
|
||||
[['email'], 'unique'],
|
||||
[['email'], 'email'],
|
||||
[['email'], 'string', 'max' => 150],
|
||||
|
@ -261,7 +261,7 @@ class Registration extends HForm
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->models['User']->language = Yii::$app->language;
|
||||
$this->models['User']->language = Yii::$app->i18n->getAllowedLanguage();
|
||||
if ($this->enableUserApproval) {
|
||||
$this->models['User']->status = User::STATUS_NEED_APPROVAL;
|
||||
$this->models['User']->registrationGroupId = $this->models['GroupUser']->group_id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user