1
0
Fork 0
mirror of synced 2024-09-29 08:51:28 +13:00

fix: hotfix for redirect param in custom templates (#7437)

* fix: hotfix for redirect param in custom templates
* fix: redirect param variables
* fix: variable typo
* chore: update comments for template variables
This commit is contained in:
Torsten Dittmann 2024-01-11 21:36:05 +01:00 committed by GitHub
parent a2d97b3b22
commit 78f7b1897e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 9 deletions

View file

@ -1011,7 +1011,6 @@ App::post('/v1/account/sessions/magic-url')
$message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-inner-base.tpl'); $message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-inner-base.tpl');
$message $message
->setParam('{{body}}', $body, escapeHtml: false) ->setParam('{{body}}', $body, escapeHtml: false)
->setParam('{{redirect}}', $url, escapeHtml: false)
->setParam('{{hello}}', $locale->getText("emails.magicSession.hello")) ->setParam('{{hello}}', $locale->getText("emails.magicSession.hello"))
->setParam('{{footer}}', $locale->getText("emails.magicSession.footer")) ->setParam('{{footer}}', $locale->getText("emails.magicSession.footer"))
->setParam('{{thanks}}', $locale->getText("emails.magicSession.thanks")) ->setParam('{{thanks}}', $locale->getText("emails.magicSession.thanks"))
@ -1066,9 +1065,10 @@ App::post('/v1/account/sessions/magic-url')
$emailVariables = [ $emailVariables = [
'direction' => $locale->getText('settings.direction'), 'direction' => $locale->getText('settings.direction'),
/* {{user}} ,{{team}} and {{project}} are required in the templates */ /* {{user}}, {{team}}, {{redirect}} and {{project}} are required in default and custom templates */
'user' => '', 'user' => '',
'team' => '', 'team' => '',
'redirect' => $url,
'project' => $project->getAttribute('name') 'project' => $project->getAttribute('name')
]; ];
@ -2456,7 +2456,6 @@ App::post('/v1/account/recovery')
$message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-inner-base.tpl'); $message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-inner-base.tpl');
$message $message
->setParam('{{body}}', $body, escapeHtml: false) ->setParam('{{body}}', $body, escapeHtml: false)
->setParam('{{redirect}}', $url, escapeHtml: false)
->setParam('{{hello}}', $locale->getText("emails.recovery.hello")) ->setParam('{{hello}}', $locale->getText("emails.recovery.hello"))
->setParam('{{footer}}', $locale->getText("emails.recovery.footer")) ->setParam('{{footer}}', $locale->getText("emails.recovery.footer"))
->setParam('{{thanks}}', $locale->getText("emails.recovery.thanks")) ->setParam('{{thanks}}', $locale->getText("emails.recovery.thanks"))
@ -2511,9 +2510,10 @@ App::post('/v1/account/recovery')
$emailVariables = [ $emailVariables = [
'direction' => $locale->getText('settings.direction'), 'direction' => $locale->getText('settings.direction'),
/* {{user}} ,{{team}} and {{project}} are required in the templates */ /* {{user}}, {{team}}, {{redirect}} and {{project}} are required in default and custom templates */
'user' => $profile->getAttribute('name'), 'user' => $profile->getAttribute('name'),
'team' => '', 'team' => '',
'redirect' => $url,
'project' => $projectName 'project' => $projectName
]; ];
@ -2708,7 +2708,6 @@ App::post('/v1/account/verification')
$message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-inner-base.tpl'); $message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-inner-base.tpl');
$message $message
->setParam('{{body}}', $body, escapeHtml: false) ->setParam('{{body}}', $body, escapeHtml: false)
->setParam('{{redirect}}', $url, escapeHtml: false)
->setParam('{{hello}}', $locale->getText("emails.verification.hello")) ->setParam('{{hello}}', $locale->getText("emails.verification.hello"))
->setParam('{{footer}}', $locale->getText("emails.verification.footer")) ->setParam('{{footer}}', $locale->getText("emails.verification.footer"))
->setParam('{{thanks}}', $locale->getText("emails.verification.thanks")) ->setParam('{{thanks}}', $locale->getText("emails.verification.thanks"))
@ -2763,9 +2762,10 @@ App::post('/v1/account/verification')
$emailVariables = [ $emailVariables = [
'direction' => $locale->getText('settings.direction'), 'direction' => $locale->getText('settings.direction'),
/* {{user}} ,{{team}} and {{project}} are required in the templates */ /* {{user}}, {{team}}, {{redirect}} and {{project}} are required in default and custom templates */
'user' => $user->getAttribute('name'), 'user' => $user->getAttribute('name'),
'team' => '', 'team' => '',
'redirect' => $url,
'project' => $projectName 'project' => $projectName
]; ];

View file

@ -557,7 +557,6 @@ App::post('/v1/teams/:teamId/memberships')
$message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-inner-base.tpl'); $message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-inner-base.tpl');
$message $message
->setParam('{{body}}', $body, escapeHtml: false) ->setParam('{{body}}', $body, escapeHtml: false)
->setParam('{{redirect}}', $url, escapeHtml: false)
->setParam('{{hello}}', $locale->getText("emails.invitation.hello")) ->setParam('{{hello}}', $locale->getText("emails.invitation.hello"))
->setParam('{{footer}}', $locale->getText("emails.invitation.footer")) ->setParam('{{footer}}', $locale->getText("emails.invitation.footer"))
->setParam('{{thanks}}', $locale->getText("emails.invitation.thanks")) ->setParam('{{thanks}}', $locale->getText("emails.invitation.thanks"))
@ -613,9 +612,10 @@ App::post('/v1/teams/:teamId/memberships')
$emailVariables = [ $emailVariables = [
'owner' => $user->getAttribute('name'), 'owner' => $user->getAttribute('name'),
'direction' => $locale->getText('settings.direction'), 'direction' => $locale->getText('settings.direction'),
/* {{user}} ,{{team}} and {{project}} are required in the templates */ /* {{user}}, {{team}}, {{redirect}} and {{project}} are required in default and custom templates */
'user' => $user->getAttribute('name'), 'user' => $user->getAttribute('name'),
'team' => $team->getAttribute('name'), 'team' => $team->getAttribute('name'),
'redirect' => $url,
'project' => $projectName 'project' => $projectName
]; ];

View file

@ -67,7 +67,8 @@ class Mails extends Action
$bodyTemplate = Template::fromFile($bodyTemplate); $bodyTemplate = Template::fromFile($bodyTemplate);
$bodyTemplate->setParam('{{body}}', $body, escapeHtml: false); $bodyTemplate->setParam('{{body}}', $body, escapeHtml: false);
foreach ($variables as $key => $value) { foreach ($variables as $key => $value) {
$bodyTemplate->setParam('{{' . $key . '}}', $value); // TODO: hotfix for redirect param
$bodyTemplate->setParam('{{' . $key . '}}', $value, escapeHtml: $key !== 'redirect');
} }
$body = $bodyTemplate->render(); $body = $bodyTemplate->render();