Add a mailTimeout parameter and display expiration date and time in confirmation mail (#309)
This commit is contained in:
parent
06e368abcc
commit
9e4db9505e
@ -14,6 +14,7 @@ use Lemonldap::NG::Portal::Simple qw(:all);
|
|||||||
use base qw(Lemonldap::NG::Portal::SharedConf Exporter);
|
use base qw(Lemonldap::NG::Portal::SharedConf Exporter);
|
||||||
use HTML::Template;
|
use HTML::Template;
|
||||||
use Encode;
|
use Encode;
|
||||||
|
use POSIX;
|
||||||
|
|
||||||
#inherits Lemonldap::NG::Portal::_SMTP
|
#inherits Lemonldap::NG::Portal::_SMTP
|
||||||
|
|
||||||
@ -135,7 +136,16 @@ sub storeMailSession {
|
|||||||
my $h = $self->getApacheSession();
|
my $h = $self->getApacheSession();
|
||||||
|
|
||||||
# Set _utime for session autoremove
|
# Set _utime for session autoremove
|
||||||
$h->{_utime} = time();
|
# Use default session timeout and mail session timeout to compute it
|
||||||
|
my $time = time();
|
||||||
|
my $timeout = $self->{timeout};
|
||||||
|
my $mailTimeout = $self->{mailTimeout} || $timeout;
|
||||||
|
|
||||||
|
$h->{_utime} = $time + ( $mailTimeout - $timeout );
|
||||||
|
|
||||||
|
# Store expiration timestamp for further use
|
||||||
|
$h->{mailSessionTimeoutTimestamp} = $time + $mailTimeout;
|
||||||
|
$self->{mailSessionTimeoutTimestamp} = $time + $mailTimeout;
|
||||||
|
|
||||||
# Store mail
|
# Store mail
|
||||||
$h->{ $self->{mailSessionKey} } =
|
$h->{ $self->{mailSessionKey} } =
|
||||||
@ -172,6 +182,11 @@ sub sendConfirmationMail {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$self->{id} = $mail_session unless $self->{id};
|
$self->{id} = $mail_session unless $self->{id};
|
||||||
|
|
||||||
|
my $h = $self->getApacheSession( $mail_session, 1 );
|
||||||
|
$self->{mailSessionTimeoutTimestamp} =
|
||||||
|
$h->{mailSessionTimeoutTimestamp};
|
||||||
|
untie %$h;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get mail address
|
# Get mail address
|
||||||
@ -216,7 +231,17 @@ sub sendConfirmationMail {
|
|||||||
$html = 1;
|
$html = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Mail date expiration
|
||||||
|
my $expTimestamp = $self->{mailSessionTimeoutTimestamp};
|
||||||
|
|
||||||
|
$self->lmLog( "Mail expiration timestamp: $expTimestamp", 'debug' );
|
||||||
|
|
||||||
|
my $expMailDate = &POSIX::strftime( "%d/%m/%Y", localtime $expTimestamp );
|
||||||
|
my $expMailTime = &POSIX::strftime( "%H:%M", localtime $expTimestamp );
|
||||||
|
|
||||||
# Replace variables in body
|
# Replace variables in body
|
||||||
|
$body =~ s/\$expMailDate/$expMailDate/g;
|
||||||
|
$body =~ s/\$expMailTime/$expMailTime/g;
|
||||||
$body =~ s/\$url/$url/g;
|
$body =~ s/\$url/$url/g;
|
||||||
$body =~ s/\$(\w+)/decode("utf8",$self->{sessionInfo}->{$1})/ge;
|
$body =~ s/\$(\w+)/decode("utf8",$self->{sessionInfo}->{$1})/ge;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user