Save current language for email invitation and show language chooser on registration form (#7381)

Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
Yuriy Bakhtin 2025-01-15 10:47:49 +01:00 committed by GitHub
parent e31c77d603
commit 056e0d4654
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,7 @@ HumHub Changelog
1.17.1 (Unreleased)
-------------------
- Fix #7377: Configured Redis cache key prefix was overwritten by the default value
- Fix #7375: Use default language for email invitation and show language chooser on registration form
- Enh #7383: Improve SelfTest for Base URL
1.17.0 (January 13, 2025)

View File

@ -88,6 +88,7 @@ class InviteController extends Controller
$userInvite->email = $email;
$userInvite->source = Invite::SOURCE_INVITE;
$userInvite->user_originator_id = Yii::$app->user->getIdentity()->id;
$userInvite->language = Yii::$app->settings->get('defaultLanguage');
$existingInvite = Invite::findOne(['email' => $email]);
if ($existingInvite !== null) {

View File

@ -52,7 +52,9 @@ final class InviteRegistrationService
{
$invite = $this->getInvite();
if ($invite !== null) {
Yii::$app->setLanguage($invite->language);
if (Yii::$app->request->post('ChooseLanguage') === null) {
Yii::$app->setLanguage($invite->language);
}
$registration->getUser()->email = $invite->email;
}
}

View File

@ -4,6 +4,7 @@ use humhub\libs\Html;
use humhub\modules\ui\form\widgets\ActiveForm;
use humhub\modules\user\models\forms\Registration;
use humhub\modules\user\widgets\AuthChoice;
use humhub\widgets\LanguageChooser;
use humhub\widgets\SiteLogo;
/**
@ -32,12 +33,15 @@ $this->pageTitle = Yii::t('UserModule.auth', 'Create Account');
<?php if ($showRegistrationForm): ?>
<?php $form = ActiveForm::begin(['id' => 'registration-form', 'enableClientValidation' => false]); ?>
<?= Html::hiddenInput('ChooseLanguage[language]', Yii::$app->language) ?>
<?= $hForm->render($form); ?>
<?php ActiveForm::end(); ?>
<?php endif; ?>
</div>
</div>
</div>
<?= LanguageChooser::widget() ?>
</div>
<script <?= Html::nonce() ?>>