Replace hidden form values on info when urldc has a QS (#2085)
This commit is contained in:
parent
8afbd2214d
commit
b512cc700c
|
@ -8,6 +8,7 @@ package Lemonldap::NG::Portal::Main;
|
||||||
use strict;
|
use strict;
|
||||||
use Mouse;
|
use Mouse;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
use URI;
|
||||||
|
|
||||||
has skinRules => ( is => 'rw' );
|
has skinRules => ( is => 'rw' );
|
||||||
|
|
||||||
|
@ -136,7 +137,7 @@ sub display {
|
||||||
AUTH_ERROR_TYPE => $req->error_type,
|
AUTH_ERROR_TYPE => $req->error_type,
|
||||||
MSG => $info,
|
MSG => $info,
|
||||||
URL => $req->{urldc},
|
URL => $req->{urldc},
|
||||||
HIDDEN_INPUTS => $self->buildHiddenForm($req),
|
HIDDEN_INPUTS => $self->buildOutgoingHiddenForm( $req, $method ),
|
||||||
ACTIVE_TIMER => $req->data->{activeTimer},
|
ACTIVE_TIMER => $req->data->{activeTimer},
|
||||||
CHOICE_PARAM => $self->conf->{authChoiceParam},
|
CHOICE_PARAM => $self->conf->{authChoiceParam},
|
||||||
CHOICE_VALUE => $req->data->{_authChoice},
|
CHOICE_VALUE => $req->data->{_authChoice},
|
||||||
|
@ -182,13 +183,14 @@ sub display {
|
||||||
|
|
||||||
# 2.1 Redirection
|
# 2.1 Redirection
|
||||||
elsif ( $req->{error} == PE_REDIRECT ) {
|
elsif ( $req->{error} == PE_REDIRECT ) {
|
||||||
|
my $method = $req->data->{redirectFormMethod} || 'get';
|
||||||
$skinfile = "redirect";
|
$skinfile = "redirect";
|
||||||
%templateParams = (
|
%templateParams = (
|
||||||
MAIN_LOGO => $self->conf->{portalMainLogo},
|
MAIN_LOGO => $self->conf->{portalMainLogo},
|
||||||
LANGS => $self->conf->{showLanguages},
|
LANGS => $self->conf->{showLanguages},
|
||||||
URL => $req->{urldc},
|
URL => $req->{urldc},
|
||||||
HIDDEN_INPUTS => $self->buildHiddenForm($req),
|
HIDDEN_INPUTS => $self->buildOutgoingHiddenForm( $req, $method ),
|
||||||
FORM_METHOD => $req->data->{redirectFormMethod} || 'get',
|
FORM_METHOD => $method,
|
||||||
(
|
(
|
||||||
$req->data->{customScript}
|
$req->data->{customScript}
|
||||||
? ( CUSTOM_SCRIPT => $req->data->{customScript} )
|
? ( CUSTOM_SCRIPT => $req->data->{customScript} )
|
||||||
|
@ -508,6 +510,29 @@ sub staticFile {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub buildOutgoingHiddenForm {
|
||||||
|
my ( $self, $req, $method ) = @_;
|
||||||
|
my @keys = keys %{ $req->{portalHiddenFormValues} };
|
||||||
|
|
||||||
|
# Redirection URL contains query string. Before displaying a form,
|
||||||
|
# we must set the query string parameters as form fields so they can
|
||||||
|
# be preserved #2085
|
||||||
|
|
||||||
|
my $uri = URI->new( $req->{urldc} );
|
||||||
|
my %query_params = $uri->query_form;
|
||||||
|
if (%query_params) {
|
||||||
|
$self->logger->debug(
|
||||||
|
"urldc contains query parameters, setting them as hidden form values"
|
||||||
|
);
|
||||||
|
$self->clearHiddenFormValue($req);
|
||||||
|
foreach ( keys %query_params ) {
|
||||||
|
$self->setHiddenFormValue( $req, $_, $query_params{$_}, "", 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self->buildHiddenForm($req);
|
||||||
|
}
|
||||||
|
|
||||||
sub buildHiddenForm {
|
sub buildHiddenForm {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
my @keys = keys %{ $req->{portalHiddenFormValues} };
|
my @keys = keys %{ $req->{portalHiddenFormValues} };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user