Enable jsRedirect (#595)
This commit is contained in:
parent
4ee99bd0f9
commit
73e0199c8b
|
@ -68,7 +68,7 @@ sub display {
|
|||
%templateParams = (
|
||||
URL => $req->{urldc},
|
||||
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' );
|
||||
|
||||
# Macros and groups
|
||||
has _macros => ( is => 'rw' );
|
||||
has _groups => ( is => 'rw' );
|
||||
has _macros => ( is => 'rw' );
|
||||
has _groups => ( is => 'rw' );
|
||||
has _jsRedirect => ( is => 'rw' );
|
||||
|
||||
# TrustedDomain regexp
|
||||
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
|
||||
foreach my $plugin ( $self->enabledPlugins ) {
|
||||
|
|
|
@ -188,14 +188,34 @@ sub autoRedirect {
|
|||
$req->{urldc} ||= $self->conf->{portal} if ( $req->mustRedirect );
|
||||
|
||||
# Redirection should be made if urldc defined
|
||||
if ( $req->{urldc} ) {
|
||||
return [ 302, [ Location => $req->{urldc}, @{ $req->respHeaders } ],
|
||||
[] ];
|
||||
}
|
||||
else {
|
||||
my ( $tpl, $prms ) = $self->display($req);
|
||||
return $self->sendHtml( $req, $tpl, params => $prms );
|
||||
if ( $req->{urldc} and not $req->param('lmError') ) {
|
||||
if ( $self->conf->{cda}
|
||||
and $req->{id}
|
||||
and $req->{urldc} !~
|
||||
m#^https?://[^/]*$self->conf->{domain}(:\d+)?/#oi
|
||||
and $self->isTrustedUrl( $req->{urldc} ) )
|
||||
{
|
||||
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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user