Allow portal JSON responses to include a rendered HTML error block (#2110)
This commit is contained in:
parent
e1767abfda
commit
8c94bf0f13
|
@ -392,6 +392,7 @@ site/templates/bootstrap/customLoginFooter.tpl
|
||||||
site/templates/bootstrap/customLoginHeader.tpl
|
site/templates/bootstrap/customLoginHeader.tpl
|
||||||
site/templates/bootstrap/decryptvalue.tpl
|
site/templates/bootstrap/decryptvalue.tpl
|
||||||
site/templates/bootstrap/error.tpl
|
site/templates/bootstrap/error.tpl
|
||||||
|
site/templates/bootstrap/errormsg.tpl
|
||||||
site/templates/bootstrap/ext2fcheck.tpl
|
site/templates/bootstrap/ext2fcheck.tpl
|
||||||
site/templates/bootstrap/footer.tpl
|
site/templates/bootstrap/footer.tpl
|
||||||
site/templates/bootstrap/globallogout.tpl
|
site/templates/bootstrap/globallogout.tpl
|
||||||
|
|
|
@ -80,6 +80,10 @@ has captcha => ( is => 'rw' );
|
||||||
# Token
|
# Token
|
||||||
has token => ( is => 'rw' );
|
has token => ( is => 'rw' );
|
||||||
|
|
||||||
|
# Whether or not to include a HTML render of the error message
|
||||||
|
# in error responses
|
||||||
|
has wantErrorRender => ( is => 'rw' );
|
||||||
|
|
||||||
# Error type
|
# Error type
|
||||||
sub error_type {
|
sub error_type {
|
||||||
my $req = shift;
|
my $req = shift;
|
||||||
|
|
|
@ -260,9 +260,19 @@ sub do {
|
||||||
if ( !$self->conf->{noAjaxHook} and $req->wantJSON ) {
|
if ( !$self->conf->{noAjaxHook} and $req->wantJSON ) {
|
||||||
$self->logger->debug('Processing to JSON response');
|
$self->logger->debug('Processing to JSON response');
|
||||||
if ( ( $err > 0 and !$req->id ) or $err eq PE_SESSIONNOTGRANTED ) {
|
if ( ( $err > 0 and !$req->id ) or $err eq PE_SESSIONNOTGRANTED ) {
|
||||||
|
my $json = { result => 0, error => $err };
|
||||||
|
if ( $req->wantErrorRender ) {
|
||||||
|
$json->{html} = $self->loadTemplate(
|
||||||
|
$req,
|
||||||
|
'errormsg',
|
||||||
|
params => {
|
||||||
|
AUTH_ERROR => $err,
|
||||||
|
AUTH_ERROR_TYPE => $req->error_type,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
return $self->sendJSONresponse(
|
return $self->sendJSONresponse(
|
||||||
$req,
|
$req, $json,
|
||||||
{ result => 0, error => $err },
|
|
||||||
code => 401,
|
code => 401,
|
||||||
headers => [
|
headers => [
|
||||||
'WWW-Authenticate' => "SSO " . $self->conf->{portal},
|
'WWW-Authenticate' => "SSO " . $self->conf->{portal},
|
||||||
|
@ -1045,7 +1055,7 @@ sub registerLogin {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $history = $req->sessionInfo->{_loginHistory} ||= {};
|
my $history = $req->sessionInfo->{_loginHistory} ||= {};
|
||||||
my $type = ( $req->authResult > 0 ? 'failed' : 'success' ) . 'Login';
|
my $type = ( $req->authResult > 0 ? 'failed' : 'success' ) . 'Login';
|
||||||
$history->{$type} ||= [];
|
$history->{$type} ||= [];
|
||||||
$self->logger->debug("Current login saved into $type");
|
$self->logger->debug("Current login saved into $type");
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<TMPL_IF NAME="AUTH_ERROR">
|
||||||
|
<div class="message message-<TMPL_VAR NAME="AUTH_ERROR_TYPE"> alert"><span trmsg="<TMPL_VAR NAME="AUTH_ERROR">"></span>
|
||||||
|
<TMPL_IF LOCKTIME>
|
||||||
|
<TMPL_VAR NAME="LOCKTIME"> <span trspan="seconds">seconds</span>.
|
||||||
|
</TMPL_IF>
|
||||||
|
</div>
|
||||||
|
</TMPL_IF>
|
Loading…
Reference in New Issue
Block a user