Commit 30b7ce63 authored by Clément OUDOT's avatar Clément OUDOT

Use main logo in mails (#1515)

parent 6b41c1d3
......@@ -83,7 +83,7 @@ sub resetPwd {
sub _reset {
my ( $self, $req ) = @_;
my ( $mailToken, $newPwd, $confirmPwd );
my ( $mailToken, $newPwd, $confirmPwd, %tplPrms );
# PASSWORD CHANGE FORM => changePwd()
if ( $req->method =~ /^POST$/i
......@@ -303,6 +303,7 @@ sub _reset {
);
# Build mail content
$tplPrms{MAIN_LOGO} = $self->conf->{portalMainLogo};
my $tr = $self->translate($req);
my $subject = $self->conf->{mailConfirmSubject};
unless ($subject) {
......@@ -319,7 +320,11 @@ sub _reset {
else {
# Use HTML template
$body = $self->loadTemplate( 'mail_confirm', filter => $tr );
$body = $self->loadTemplate(
'mail_confirm',
filter => $tr,
params => \%tplPrms
);
$html = 1;
}
......@@ -424,6 +429,7 @@ sub changePwd {
$req->{sessionInfo}->{ $self->conf->{mailSessionKey} } );
# Build mail content
$tplPrms{MAIN_LOGO} = $self->conf->{portalMainLogo};
my $tr = $self->translate($req);
my $subject = $self->conf->{mailSubject};
unless ($subject) {
......
......@@ -111,6 +111,7 @@ sub register {
# Parameters check
sub _register {
my ( $self, $req ) = @_;
my %tplPrms;
# Check if it's a first access
unless ( ( $req->method =~ /^POST$/i and $req->param('mail') )
......@@ -295,6 +296,7 @@ sub _register {
);
# Build mail content
$tplPrms{MAIN_LOGO} = $self->conf->{portalMainLogo};
my $tr = $self->translate($req);
my $subject = $self->conf->{registerConfirmSubject};
unless ($subject) {
......@@ -305,7 +307,11 @@ sub _register {
my $html = 1;
# Use HTML template
$body = $self->loadTemplate( 'mail_register_confirm', filter => $tr );
$body = $self->loadTemplate(
'mail_register_confirm',
filter => $tr,
params => \%tplPrms
);
# Replace variables in body
$body =~ s/\$expMailDate/$req->data->{expMailDate}/g;
......@@ -349,6 +355,7 @@ sub _register {
}
# Build mail content
$tplPrms{MAIN_LOGO} = $self->conf->{portalMainLogo};
my $tr = $self->translate($req);
my $subject = $self->conf->{registerDoneSubject};
unless ($subject) {
......@@ -359,7 +366,11 @@ sub _register {
my $html = 1;
# Use HTML template
$body = $self->loadTemplate( 'mail_register_done', filter => $tr );
$body = $self->loadTemplate(
'mail_register_done',
filter => $tr,
params => \%tplPrms
);
# Build portal url
my $url = $self->conf->{portal};
......
<html>
<body>
<div id="page" style="background:#000;font-family:sans-serif;font-size:12pt;color:#fff;padding:5px 20px;">
<div id="page" style="font-family:sans-serif;font-size:12pt;padding:5px 20px;">
<div id="header" style="text-align:right;"><h1>LemonLDAP::NG</h1></div>
<div id="header" style="text-align:center;"><img src="cid:logo:../../htdocs/static/<TMPL_VAR NAME="MAIN_LOGO">" style="max-width:150px;" /></div>
<div id="content" style="color:#000;background:#eee;padding:5px 10px;margin:10px 0;">
<div id="content" style="padding:5px 10px;margin:10px 0;">
......@@ -32,6 +32,9 @@ SKIP: {
}
);
# Create main logo to avoid mail send error
`touch site/htdocs/static/common/logos/test.png`;
# Test normal first access
# ------------------------
ok( $res = $client->_get( '/register', accept => 'text/html' ),
......@@ -103,6 +106,9 @@ SKIP: {
'Try to authenticate'
);
expectCookie($res);
# Delete main logo
`rm site/htdocs/static/common/logos/test.png`;
}
count($maintests);
......
......@@ -37,6 +37,9 @@ SKIP: {
}
);
# Create main logo to avoid mail send error
`touch site/htdocs/static/common/logos/test.png`;
# Test form
# ------------------------
ok( $res = $client->_get( '/resetpwd', accept => 'text/html' ),
......@@ -98,6 +101,9 @@ SKIP: {
);
ok( mail() =~ /Your password was changed/, 'Password was changed' );
# Delete main logo
`rm site/htdocs/static/common/logos/test.png`;
#print STDERR Dumper($query);
}
count($maintests);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment