Enable jsRedirect (#595)
This commit is contained in:
parent
4ee99bd0f9
commit
73e0199c8b
|
@ -68,7 +68,7 @@ sub display {
|
||||||
%templateParams = (
|
%templateParams = (
|
||||||
URL => $req->{urldc},
|
URL => $req->{urldc},
|
||||||
HIDDEN_INPUTS => $self->buildHiddenForm(),
|
HIDDEN_INPUTS => $self->buildHiddenForm(),
|
||||||
FORM_METHOD => $self->conf->{redirectFormMethod},
|
FORM_METHOD => $req->datas->{redirectFormMethod} || 'get',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,9 @@ has _authentication => ( is => 'rw' );
|
||||||
has _userDB => ( is => 'rw' );
|
has _userDB => ( is => 'rw' );
|
||||||
|
|
||||||
# Macros and groups
|
# Macros and groups
|
||||||
has _macros => ( is => 'rw' );
|
has _macros => ( is => 'rw' );
|
||||||
has _groups => ( is => 'rw' );
|
has _groups => ( is => 'rw' );
|
||||||
|
has _jsRedirect => ( is => 'rw' );
|
||||||
|
|
||||||
# TrustedDomain regexp
|
# TrustedDomain regexp
|
||||||
has trustedDomainsRe => ( is => 'rw' );
|
has trustedDomainsRe => ( is => 'rw' );
|
||||||
|
@ -235,6 +236,12 @@ sub reloadConf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$self->{_jsRedirect} =
|
||||||
|
HANDLER->tsv->{jail}->jail_reval(
|
||||||
|
"sub{return " . HANDLER->substitute( $self->conf->{jsRedirect} ) . "}" )
|
||||||
|
or $self->lmLog(
|
||||||
|
'jsRedirect returns an error: ' . HANDLER->tsv->{jail}->error,
|
||||||
|
'error' );
|
||||||
|
|
||||||
# Load plugins
|
# Load plugins
|
||||||
foreach my $plugin ( $self->enabledPlugins ) {
|
foreach my $plugin ( $self->enabledPlugins ) {
|
||||||
|
|
|
@ -188,14 +188,34 @@ sub autoRedirect {
|
||||||
$req->{urldc} ||= $self->conf->{portal} if ( $req->mustRedirect );
|
$req->{urldc} ||= $self->conf->{portal} if ( $req->mustRedirect );
|
||||||
|
|
||||||
# Redirection should be made if urldc defined
|
# Redirection should be made if urldc defined
|
||||||
if ( $req->{urldc} ) {
|
if ( $req->{urldc} and not $req->param('lmError') ) {
|
||||||
return [ 302, [ Location => $req->{urldc}, @{ $req->respHeaders } ],
|
if ( $self->conf->{cda}
|
||||||
[] ];
|
and $req->{id}
|
||||||
}
|
and $req->{urldc} !~
|
||||||
else {
|
m#^https?://[^/]*$self->conf->{domain}(:\d+)?/#oi
|
||||||
my ( $tpl, $prms ) = $self->display($req);
|
and $self->isTrustedUrl( $req->{urldc} ) )
|
||||||
return $self->sendHtml( $req, $tpl, params => $prms );
|
{
|
||||||
|
my $ssl = $req->{urldc} =~ /^https/;
|
||||||
|
$self->lmLog( 'CDA request', 'debug' );
|
||||||
|
$req->{urldc} .= ( $req->{urldc} =~ /\?/ ? '&' : '?' )
|
||||||
|
. (
|
||||||
|
( $self->conf->{securedCookie} < 2 or $ssl )
|
||||||
|
? "$self->conf->{cookieName}=$self->{id}"
|
||||||
|
: "$self->conf->{cookieName}http="
|
||||||
|
. $self->{sessionInfo}->{_httpSession}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ( $self->_jsRedirect->() ) {
|
||||||
|
$req->error(PE_REDIRECT);
|
||||||
|
$req->datas->{redirectFormMethod} = "get";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return [ 302, [ Location => $req->{urldc}, @{ $req->respHeaders } ],
|
||||||
|
[] ];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
my ( $tpl, $prms ) = $self->display($req);
|
||||||
|
return $self->sendHtml( $req, $tpl, params => $prms );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Try to recover the session corresponding to id and return session datas.
|
# Try to recover the session corresponding to id and return session datas.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user