Update mail templates to no longer use string substitution (#2495)

2620-ppolicy-binding
Maxime Besson 4 years ago
parent d696853556
commit 297dc830af
  1. 3
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Mail2F.pm
  2. 10
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/CertificateResetByMail.pm
  3. 17
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/MailPasswordReset.pm
  4. 30
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/Register.pm
  5. 4
      lemonldap-ng-portal/site/templates/common/mail_2fcode.tpl
  6. 4
      lemonldap-ng-portal/site/templates/common/mail_certificateConfirm.tpl
  7. 2
      lemonldap-ng-portal/site/templates/common/mail_certificateReset.tpl
  8. 4
      lemonldap-ng-portal/site/templates/common/mail_confirm.tpl
  9. 2
      lemonldap-ng-portal/site/templates/common/mail_footer.tpl
  10. 4
      lemonldap-ng-portal/site/templates/common/mail_password.tpl
  11. 4
      lemonldap-ng-portal/site/templates/common/mail_register_confirm.tpl
  12. 8
      lemonldap-ng-portal/site/templates/common/mail_register_done.tpl

@ -103,12 +103,15 @@ sub run {
'mail_2fcode',
filter => $tr,
params => {
code => $code,
},
);
$html = 1;
}
# Replace variables in body
# FIXME: kept for compatibility with 2.0.0 mail templates
# in future versions this should only happen for plaintext emails
$body =~ s/\$code/$code/g;
$body =~ s/\$(\w+)/$req->{sessionInfo}->{$1} || ''/ge;

@ -379,12 +379,18 @@ sub _certificateReset {
$req,
'mail_certificateConfirm',
filter => $tr,
params => {},
params => {
expMailDate => $req->data->{expMailDate},
expMailTime => $req->data->{expMailTime},
url => $url,
},
);
$html = 1;
}
# Replace variables in body
# FIXME: kept for compatibility with 2.0.0 mail templates
# in future versions this should only happen for plaintext emails
$body =~ s/\$expMailDate/$req->data->{expMailDate}/ge;
$body =~ s/\$expMailTime/$req->data->{expMailTime}/ge;
$body =~ s/\$url/$url/g;
@ -563,6 +569,8 @@ sub modifyCertificate {
}
# Replace variables in body
# FIXME: kept for compatibility with 2.0.0 mail templates
# in future versions this should only happen for plaintext emails
$body =~ s/\$(\w+)/$req->{sessionInfo}->{$1} || ''/ge;
# Send mail

@ -343,12 +343,18 @@ sub _reset {
$req,
'mail_confirm',
filter => $tr,
params => {},
params => {
expMailDate => $req->data->{expMailDate},
expMailTime => $req->data->{expMailTime},
url => $url,
},
);
$html = 1;
}
# Replace variables in body
# FIXME: kept for compatibility with 2.0.0 mail templates
# in future versions this should only happen for plaintext emails
$body =~ s/\$expMailDate/$req->data->{expMailDate}/ge;
$body =~ s/\$expMailTime/$req->data->{expMailTime}/ge;
$body =~ s/\$url/$url/g;
@ -503,6 +509,8 @@ sub changePwd {
}
my $body;
my $html;
my $password = $req->data->{newpassword};
if ( $self->conf->{mailBody} ) {
# We use a specific text message, no html
@ -515,13 +523,16 @@ sub changePwd {
$req,
'mail_password',
filter => $tr,
params => {%tplPrms},
params => {
%tplPrms, password => $password,
},
);
$html = 1;
}
# Replace variables in body
my $password = $req->data->{newpassword};
# FIXME: kept for compatibility with 2.0.0 mail templates
# in future versions this should only happen for plaintext emails
$body =~ s/\$password/$password/g;
$body =~ s/\$(\w+)/$req->{sessionInfo}->{$1} || ''/ge;

@ -314,10 +314,17 @@ sub _register {
$req,
'mail_register_confirm',
filter => $tr,
params => {},
params => {
expMailDate => $req->data->{expMailDate},
expMailTime => $req->data->{expMailTime},
url => $url,
%{ $req->data->{registerInfo} || {} },
},
);
# Replace variables in body
# FIXME: kept for compatibility with 2.0.0 mail templates
# in future versions this should only happen for plaintext emails
$body =~ s/\$expMailDate/$req->data->{expMailDate}/g;
$body =~ s/\$expMailTime/$req->data->{expMailTime}/g;
$body =~ s/\$url/$url/g;
@ -368,14 +375,6 @@ sub _register {
my $body;
my $html = 1;
# Use HTML template
$body = $self->loadMailTemplate(
$req,
'mail_register_done',
filter => $tr,
params => {},
);
# Build portal url
my $url = $self->conf->{portal};
$url =~ s#/*$##;
@ -387,7 +386,20 @@ sub _register {
( $req_url ? ( url => $req_url ) : () ),
);
# Use HTML template
$body = $self->loadMailTemplate(
$req,
'mail_register_done',
filter => $tr,
params => {
url => $url,
%{ $req->data->{registerInfo} || {} },
},
);
# Replace variables in body
# FIXME: kept for compatibility with 2.0.0 mail templates
# in future versions this should only happen for plaintext emails
$body =~ s/\$url/$url/g;
$body =~ s/\$(\w+)/$req->data->{registerInfo}->{$1}/ge;

@ -1,10 +1,10 @@
<TMPL_INCLUDE NAME="mail_header.tpl">
<span>
<span trspan="hello">Hello</span> $cn,<br />
<span trspan="hello">Hello</span> <TMPL_VAR NAME="session_cn" ESCAPE=HTML>,<br />
<br />
<span trspan="yourLoginCodeIs">Your login code is</span>
<b>$code</b><br/>
<b><TMPL_VAR NAME="code" ESCAPE=HTML></b><br/>
</span>
<TMPL_INCLUDE NAME="mail_footer.tpl">

@ -1,10 +1,10 @@
<TMPL_INCLUDE NAME="mail_header.tpl">
<p>
<span trspan="hello">Hello</span> $cn,<br />
<span trspan="hello">Hello</span> <TMPL_VAR NAME="session_cn" ESCAPE=HTML>,<br />
<br />
<span><img src="cid:arrow:../common/bullet_go.png" alt="go"/></span>
<a href="$url" style="text-decoration:none;color:orange;">
<a href="<TMPL_VAR NAME="url" ESCAPE=HTML>" style="text-decoration:none;color:orange;">
<span trspan="click2ResetCertificate">Click here to reset your certificate</span>
</a>
</p>

@ -1,7 +1,7 @@
<TMPL_INCLUDE NAME="mail_header.tpl">
<p>
<span trspan="hello">Hello</span> $cn,<br />
<span trspan="hello">Hello</span> <TMPL_VAR NAME="session_cn" ESCAPE=HTML>,<br />
<br />
<span trspan="resetCertificateOK">Your certificate has been successfully reset!</span>
</p>

@ -1,10 +1,10 @@
<TMPL_INCLUDE NAME="mail_header.tpl">
<p>
<span trspan="hello">Hello</span> $cn,<br />
<span trspan="hello">Hello</span> <TMPL_VAR NAME="session_cn" ESCAPE=HTML>,<br />
<br />
<span><img src="cid:arrow:../common/bullet_go.png" alt="go"/></span>
<a href="$url" style="text-decoration:none;color:orange;">
<a href="<TMPL_VAR NAME="url" ESCAPE=HTML>" style="text-decoration:none;color:orange;">
<span trspan="click2Reset">Click here to reset your password</span>
</a>
</p>

@ -4,7 +4,7 @@
<p>
<span trspan="autoMail">This mail was sent automatically</span><br />
<span trspan="requestIssuedFromIP">The request was issued from IP</span>
$ipAddr
<TMPL_VAR NAME="session_ipAddr" ESCAPE=HTML>
</p>
</div>

@ -1,12 +1,12 @@
<TMPL_INCLUDE NAME="mail_header.tpl">
<p>
<span trspan="hello">Hello</span> $cn,<br />
<span trspan="hello">Hello</span> <TMPL_VAR NAME="session_cn" ESCAPE=HTML>,<br />
<br />
<TMPL_IF NAME="RESET">
<span trspan="newPwdIs">Your new password is</span>
<span><img src="cid:key:../common/key.png" alt="key"/></span>
<b>$password</b>
<b><TMPL_VAR NAME="password" ESCAPE=HTML></b>
<TMPL_ELSE>
<span trspan="pwdChanged">Your password has been successfully changed!</span>
</TMPL_IF>

@ -1,10 +1,10 @@
<TMPL_INCLUDE NAME="mail_header.tpl">
<p>
<span trspan="hello">Hello</span> $firstname $lastname,<br />
<span trspan="hello">Hello</span> <TMPL_VAR NAME="firstname" ESCAPE=HTML> <TMPL_VAR NAME="lastname" ESCAPE=HTML>,<br />
<br />
<span><img src="cid:arrow:../common/bullet_go.png" alt="go"/></span>
<a href="$url" style="text-decoration:none;color:orange;">
<a href="<TMPL_VAR NAME="url" ESCAPE=HTML>" style="text-decoration:none;color:orange;">
<span trspan="click2Register">Click here to confirm your account registration</span>
</a>
</p>

@ -1,19 +1,19 @@
<TMPL_INCLUDE NAME="mail_header.tpl">
<p>
<span trspan="hello">Hello</span> $firstname $lastname,<br />
<span trspan="hello">Hello</span> <TMPL_VAR NAME="firstname" ESCAPE=HTML> <TMPL_VAR NAME="lastname" ESCAPE=HTML>,<br />
<br />
<span trspan="accountCreated">Your account was successfully created.</span>
<br />
<br />
<span trspan="yourLoginIs">Your login is</span>
<span><img src="cid:key:../common/bullet_go.png" alt="go"/></span>
<b>$login</b>
<b><TMPL_VAR NAME="login" ESCAPE=HTML></b>
<br />
<span trspan="pwdIs">Your password is</span>
<span><img src="cid:key:../common/key.png" alt="key"/></span>
<b>$password</b>
<b><TMPL_VAR NAME="password" ESCAPE=HTML></b>
</p>
<p><a href="$url"><span trspan="goToPortal">Click here to access to portal</span></a></p>
<p><a href="<TMPL_VAR NAME="url" ESCAPE=HTML>"><span trspan="goToPortal">Click here to access to portal</span></a></p>
<TMPL_INCLUDE NAME="mail_footer.tpl">

Loading…
Cancel
Save