Fix Ajax responses when rejected (current system broken by CORS)

This commit is contained in:
Xavier Guimard 2020-04-08 11:38:00 +02:00
parent 557fa3f74c
commit f4976d85fa

View File

@ -144,6 +144,18 @@ sub _authAndTrace {
}
}
elsif ( $res < 400 ) {
if ( $req->wantJSON ) {
my %h = ( $req->spliceHdrs );
my $host = $req->env->{HTTP_HOST};
if ( $h{Location}
and $h{Location} =~ m#^\Q$self->{portal}\E#
and $h{Location} !~ m#^https?://$host# )
{
return [
401, [ 'WWW-Authenticate' => 'SSO ' . $self->{portal} ], []
];
}
}
return [ $res, [ $req->spliceHdrs ], [] ];
}
else {