Return ciphered id in JSON response if notif is pending
This commit is contained in:
parent
e05b51c9aa
commit
df6727ffbd
|
@ -5,7 +5,7 @@ use Mouse;
|
|||
use JSON qw(from_json);
|
||||
use POSIX qw(strftime);
|
||||
|
||||
our $VERSION = '2.0.12';
|
||||
our $VERSION = '2.0.15';
|
||||
|
||||
no warnings 'redefine';
|
||||
|
||||
|
@ -178,9 +178,8 @@ sub getNotifBack {
|
|||
|
||||
# Search for Lemonldap::NG cookie (ciphered)
|
||||
my $id;
|
||||
unless ( $id = $req->cookies->{ $self->{conf}->{cookieName} } ) {
|
||||
return $self->p->sendError( $req, 'No cookie found', 401 );
|
||||
}
|
||||
return $self->p->sendError( $req, 'No cookie found', 401 )
|
||||
unless ( $id = $req->cookies->{ $self->{conf}->{cookieName} } );
|
||||
|
||||
if ( $req->param('cancel') ) {
|
||||
$self->logger->debug('Cancel called -> remove ciphered cookie');
|
||||
|
@ -197,12 +196,13 @@ sub getNotifBack {
|
|||
return $self->p->do( $req, [] );
|
||||
}
|
||||
|
||||
# Look if all notifications have been accepted. If not, redirect to
|
||||
# portal
|
||||
# Look if all notifications have been accepted.
|
||||
# If not, redirect to Portal
|
||||
|
||||
# Try to decrypt Lemonldap::NG ciphered cookie
|
||||
$id = $self->p->HANDLER->tsv->{cipher}->decrypt($id)
|
||||
or return $self->p->sendError( $req, 'Unable to decrypt', 400 );
|
||||
or
|
||||
return $self->p->sendError( $req, 'Unable to decrypt ciphered id', 400 );
|
||||
|
||||
# Check that session exists
|
||||
$req->userData( $self->p->HANDLER->retrieveSession( $req, $id ) )
|
||||
|
|
|
@ -236,9 +236,8 @@ sub getNotifBack {
|
|||
|
||||
# Search for Lemonldap::NG cookie (ciphered)
|
||||
my $id;
|
||||
unless ( $id = $req->cookies->{ $self->{conf}->{cookieName} } ) {
|
||||
return $self->p->sendError( $req, 'No cookie found', 401 );
|
||||
}
|
||||
return $self->p->sendError( $req, 'No cookie found', 401 )
|
||||
unless ( $id = $req->cookies->{ $self->{conf}->{cookieName} } );
|
||||
|
||||
if ( $req->param('cancel') ) {
|
||||
$self->logger->debug('Cancel called -> remove ciphered cookie');
|
||||
|
@ -255,12 +254,12 @@ sub getNotifBack {
|
|||
return $self->p->do( $req, [] );
|
||||
}
|
||||
|
||||
# Look if all notifications have been accepted. If not, redirect to
|
||||
# portal
|
||||
# Look if all notifications have been accepted.
|
||||
# If not, redirect to Portal
|
||||
|
||||
# Try to decrypt Lemonldap::NG ciphered cookie
|
||||
$id = $self->p->HANDLER->tsv->{cipher}->decrypt($id)
|
||||
or return $self->sendError( $req, 'Unable to decrypt', 500 );
|
||||
or return $self->sendError( $req, 'Unable to decrypt ciphered id', 400 );
|
||||
|
||||
# Check that session exists
|
||||
$req->userData( $self->p->HANDLER->retrieveSession( $req, $id ) )
|
||||
|
@ -381,7 +380,6 @@ sub getNotifBack {
|
|||
|
||||
# One pending notification has been found and not accepted,
|
||||
# restart process to display pending notifications
|
||||
# TODO: is it a good idea to launch all 'endAuth' subs ?
|
||||
$self->logger->debug(
|
||||
'Pending notification has been found and not accepted');
|
||||
return $self->p->do( $req, [ @{ $self->p->endAuth } ] );
|
||||
|
|
|
@ -208,13 +208,10 @@ sub refresh {
|
|||
if (/^_/) {
|
||||
|
||||
# But not OIDC tokens, which can be refreshed
|
||||
if (
|
||||
delete $data{$_}
|
||||
if (
|
||||
/^(_oidc_access_token|_oidc_refresh_token|_oidc_access_token_eol)$/
|
||||
)
|
||||
{
|
||||
delete $data{$_};
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
# Other variables should be refreshed
|
||||
|
@ -306,14 +303,10 @@ sub do {
|
|||
}
|
||||
|
||||
# Update history
|
||||
if ( $err == PE_SENDRESPONSE ) {
|
||||
return $req->response;
|
||||
}
|
||||
return $req->response if $err == PE_SENDRESPONSE;
|
||||
|
||||
# Remove userData if authentication fails
|
||||
if ( $err == PE_BADCREDENTIALS or $err == PE_BADOTP ) {
|
||||
$req->userData( {} );
|
||||
}
|
||||
$req->userData( {} ) if ( $err == PE_BADCREDENTIALS or $err == PE_BADOTP );
|
||||
|
||||
if ( !$self->conf->{noAjaxHook} and $req->wantJSON ) {
|
||||
$self->logger->debug('Processing to JSON response');
|
||||
|
@ -342,7 +335,15 @@ sub do {
|
|||
elsif ( $err > 0 and $err != PE_PASSWORD_OK and $err != PE_LOGOUT_OK ) {
|
||||
return $self->sendJSONresponse(
|
||||
$req,
|
||||
{ result => 0, error => $err },
|
||||
{
|
||||
result => 0,
|
||||
error => $err,
|
||||
(
|
||||
$err == PE_NOTIFICATION && $req->id
|
||||
? ( ciphered_id => $req->id )
|
||||
: ()
|
||||
)
|
||||
},
|
||||
code => 400
|
||||
);
|
||||
}
|
||||
|
@ -956,7 +957,6 @@ sub sendHtml {
|
|||
{
|
||||
$self->logger->debug(
|
||||
"Add SAML Discovery Protocol URL in CSP form-action");
|
||||
|
||||
$csp .= " " . $self->conf->{samlDiscoveryProtocolURL};
|
||||
}
|
||||
$csp .= ';';
|
||||
|
@ -1168,12 +1168,11 @@ sub _sumUpSession {
|
|||
$withoutUser
|
||||
? {}
|
||||
: { user => $session->{ $self->conf->{whatToTrace} } };
|
||||
$res->{$_} = $session->{$_}
|
||||
foreach (
|
||||
$res->{$_} = $session->{$_} foreach (
|
||||
"_utime", "ipAddr",
|
||||
keys %{ $self->conf->{sessionDataToRemember} },
|
||||
keys %{ $self->pluginSessionDataToRemember }
|
||||
);
|
||||
);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue