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/decryptvalue.tpl
|
||||
site/templates/bootstrap/error.tpl
|
||||
site/templates/bootstrap/errormsg.tpl
|
||||
site/templates/bootstrap/ext2fcheck.tpl
|
||||
site/templates/bootstrap/footer.tpl
|
||||
site/templates/bootstrap/globallogout.tpl
|
||||
|
|
|
@ -80,6 +80,10 @@ has captcha => ( is => 'rw' );
|
|||
# Token
|
||||
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
|
||||
sub error_type {
|
||||
my $req = shift;
|
||||
|
|
|
@ -260,9 +260,19 @@ sub do {
|
|||
if ( !$self->conf->{noAjaxHook} and $req->wantJSON ) {
|
||||
$self->logger->debug('Processing to JSON response');
|
||||
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(
|
||||
$req,
|
||||
{ result => 0, error => $err },
|
||||
$req, $json,
|
||||
code => 401,
|
||||
headers => [
|
||||
'WWW-Authenticate' => "SSO " . $self->conf->{portal},
|
||||
|
@ -1045,7 +1055,7 @@ sub registerLogin {
|
|||
}
|
||||
|
||||
my $history = $req->sessionInfo->{_loginHistory} ||= {};
|
||||
my $type = ( $req->authResult > 0 ? 'failed' : 'success' ) . 'Login';
|
||||
my $type = ( $req->authResult > 0 ? 'failed' : 'success' ) . 'Login';
|
||||
$history->{$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