Fix Ajax responses when rejected

This commit is contained in:
Xavier Guimard 2020-04-08 11:38:00 +02:00
parent 01424a71ac
commit c09797ff11
1 changed files with 12 additions and 0 deletions

View File

@ -143,6 +143,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 {