Commit 84c02a1c authored by Clément OUDOT's avatar Clément OUDOT

Mail customization (plain text only) with parameter mailBody

parent 50e88a68
......@@ -77,6 +77,9 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new(
# Mail subject
#mailSubject => "Password reset",
# Mail body (can use $password for generated password, and other session infos, like $cn)
#mailBody => 'Hello $cn,\n\nYour new password is $password',
# LDAP filter to use
#mailLDAPFilter => '(&(mail=$mail)(objectClass=inetOrgPerson))',
......
......@@ -9,7 +9,7 @@ use Lemonldap::NG::Portal::Simple;
use Lemonldap::NG::Portal::_LDAP 'ldap'; #link protected ldap
use Lemonldap::NG::Portal::UserDBLDAP; #inherits
our $VERSION = '0.1';
our $VERSION = '0.2';
*_formateFilter = *Lemonldap::NG::Portal::UserDBLDAP::formateFilter;
*_search = *Lemonldap::NG::Portal::UserDBLDAP::search;
......@@ -108,13 +108,19 @@ sub resetPasswordByMail {
}
# Send new password by mail
$self->{mailBody} =~ s/\$password/$password/g;
$self->{mailBody} =~ s/\$(\w+)/$self->{sessionInfo}->{$1}/g;
$self->lmLog("SMTP From ".$self->{mailFrom},'debug');
$self->lmLog("SMTP To ".$self->{mail},'debug');
$self->lmLog("SMTP Subject ".$self->{mailSubject},'debug');
$self->lmLog("SMTP Body ".$self->{mailBody},'debug');
eval {
my $message = MIME::Lite->new(
From => $self->{mailFrom},
To => $self->{mail},
Subject => $self->{mailSubject},
Type => "TEXT",
Data => "Your new password: $password\n",
Data => $self->{mailBody},
);
$self->{SMTPServer} ? $message->send("smtp",$self->{SMTPServer}) : $message->send();
};
......@@ -123,7 +129,6 @@ sub resetPasswordByMail {
return PE_ERROR;
}
$self->lmLog("New password sent to ".$self->{mail},'debug');
PE_PASSWORD_OK;
}
......
......@@ -34,7 +34,7 @@ use Safe;
#inherits Apache::Session
#link Lemonldap::NG::Common::Apache::Session::SOAP protected globalStorage
our $VERSION = '0.87';
our $VERSION = '0.88';
use base qw(Lemonldap::NG::Common::CGI Exporter);
our @ISA;
......@@ -136,6 +136,7 @@ sub new {
$self->{randomPasswordRegexp} ||= '[A-Z]{3}[a-z]{5}.\d{2}';
$self->{mailFrom} ||= "noreply@".$domain;
$self->{mailSubject} ||= "Change password request";
$self->{mailBody} ||= 'Your new password is $password';
# Authentication and userDB module are required and have to be in @ISA
foreach (qw(authentication userDB passwordDB)) {
......@@ -537,8 +538,8 @@ sub process {
$self->{error} = $self->_subProcess(
qw(controlUrlOrigin checkNotifBack controlExistingSession
SAMLForUnAuthUser authInit extractFormInfo userDBInit getUser
setAuthSessionInfo passwordDBInit modifyPassword resetPasswordByMail
setSessionInfo setMacros setGroups authenticate store buildCookie
setAuthSessionInfo passwordDBInit modifyPassword setSessionInfo
resetPasswordByMail setMacros setGroups authenticate store buildCookie
checkNotification SAMLForAuthUser autoRedirect)
);
$self->updateStatus;
......@@ -694,8 +695,6 @@ sub existingSession {
# . modifyPassword() : must be implemented in PasswordDB* module
# . resetPasswordByMail() : must be implemented in PasswordDB* module
##@apmethod int setSessionInfo()
# 9) Call setSessionInfo() in User* module and set ipAddr and startTime
#@return Lemonldap::NG::Portal constant
......@@ -716,6 +715,8 @@ sub setSessionInfo {
return $self->SUPER::setSessionInfo();
}
# . resetPasswordByMail() : must be implemented in PasswordDB* module
##@apmethod int setMacro()
# 10) macro mechanism.
# * store macro results in $self->{sessionInfo}
......
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