Improve code (#1386)
This commit is contained in:
parent
441df6e7ea
commit
548032fbe0
|
@ -295,24 +295,24 @@ sub run {
|
||||||
return $self->p->sendError( $req, "Corrupted session", 500 );
|
return $self->p->sendError( $req, "Corrupted session", 500 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
$self->logger->debug("No 2F Device found");
|
$self->logger->debug("No 2F Device found");
|
||||||
$_2fDevices = [];
|
$_2fDevices = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete TOTP 2F device
|
# my @keep = ();
|
||||||
my @keep = ();
|
# while (@$_2fDevices) {
|
||||||
while (@$_2fDevices) {
|
# my $element = shift @$_2fDevices;
|
||||||
my $element = shift @$_2fDevices;
|
# $self->logger->debug("Looking for 2F device to delete ...");
|
||||||
$self->logger->debug("Looking for 2F device to delete ...");
|
# push @keep, $element unless ( $element->{epoch} eq $epoch );
|
||||||
push @keep, $element unless ( $element->{epoch} eq $epoch );
|
# }
|
||||||
}
|
|
||||||
|
|
||||||
|
# Delete TOTP 2F device
|
||||||
|
@$_2fDevices = grep { $_->{epoch} ne $epoch } @$_2fDevices;
|
||||||
$self->logger->debug(
|
$self->logger->debug(
|
||||||
"Delete 2F Device : { type => 'TOTP', epoch => $epoch }");
|
"Delete 2F Device : { type => 'TOTP', epoch => $epoch }");
|
||||||
$self->p->updatePersistentSession( $req,
|
$self->p->updatePersistentSession( $req,
|
||||||
{ _2fDevices => to_json( \@keep ) } );
|
{ _2fDevices => to_json( $_2fDevices ) } );
|
||||||
$self->userLogger->notice('TOTP deletion succeed');
|
$self->userLogger->notice('TOTP deletion succeed');
|
||||||
return [
|
return [
|
||||||
200,
|
200,
|
||||||
|
|
|
@ -287,17 +287,19 @@ sub run {
|
||||||
$_2fDevices = [];
|
$_2fDevices = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
my @keep = ();
|
# my @keep = ();
|
||||||
while (@$_2fDevices) {
|
# while (@$_2fDevices) {
|
||||||
my $element = shift @$_2fDevices;
|
# my $element = shift @$_2fDevices;
|
||||||
$self->logger->debug("Looking for 2F device to delete ...");
|
# $self->logger->debug("Looking for 2F device to delete ...");
|
||||||
push @keep, $element unless ( $element->{epoch} eq $epoch );
|
# push @keep, $element unless ( $element->{epoch} eq $epoch );
|
||||||
}
|
# }
|
||||||
|
|
||||||
|
# Delete U2F device
|
||||||
|
@$_2fDevices = grep { $_->{epoch} ne $epoch } @$_2fDevices;
|
||||||
$self->logger->debug(
|
$self->logger->debug(
|
||||||
"Delete 2F Device : { type => 'U2F', epoch => $epoch }");
|
"Delete 2F Device : { type => 'U2F', epoch => $epoch }");
|
||||||
$self->p->updatePersistentSession( $req,
|
$self->p->updatePersistentSession( $req,
|
||||||
{ _2fDevices => to_json( \@keep ) } );
|
{ _2fDevices => to_json( $_2fDevices ) } );
|
||||||
$self->userLogger->notice('U2F key unregistration succeed');
|
$self->userLogger->notice('U2F key unregistration succeed');
|
||||||
return [
|
return [
|
||||||
200,
|
200,
|
||||||
|
|
|
@ -176,31 +176,30 @@ sub run {
|
||||||
return $self->p->sendError( $req, "Corrupted session", 500 );
|
return $self->p->sendError( $req, "Corrupted session", 500 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
$self->logger->debug("No 2F Device found");
|
$self->logger->debug("No 2F Device found");
|
||||||
$_2fDevices = [];
|
$_2fDevices = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
my @keep = ();
|
# my @keep = ();
|
||||||
while (@$_2fDevices) {
|
# while (@$_2fDevices) {
|
||||||
my $element = shift @$_2fDevices;
|
# my $element = shift @$_2fDevices;
|
||||||
$self->logger->debug("Looking for 2F device to delete ...");
|
# $self->logger->debug("Looking for 2F device to delete ...");
|
||||||
push @keep, $element unless ( $element->{epoch} eq $epoch );
|
# push @keep, $element unless ( $element->{epoch} eq $epoch );
|
||||||
}
|
# }
|
||||||
|
|
||||||
|
# Delete Yubikey device
|
||||||
|
@$_2fDevices = grep { $_->{epoch} ne $epoch } @$_2fDevices;
|
||||||
$self->logger->debug(
|
$self->logger->debug(
|
||||||
"Delete 2F Device : { type => 'UBK', epoch => $epoch }");
|
"Delete 2F Device : { type => 'UBK', epoch => $epoch }");
|
||||||
$self->p->updatePersistentSession( $req,
|
$self->p->updatePersistentSession( $req,
|
||||||
{ _2fDevices => to_json( \@keep ) } );
|
{ _2fDevices => to_json( $_2fDevices ) } );
|
||||||
|
|
||||||
$self->userLogger->notice('Yubikey deletion succeed');
|
$self->userLogger->notice('Yubikey deletion succeed');
|
||||||
return [
|
return [
|
||||||
200,
|
200,
|
||||||
[ 'Content-Type' => 'application/json', 'Content-Length' => 12, ],
|
[ 'Content-Type' => 'application/json', 'Content-Length' => 12, ],
|
||||||
['{"result":1}']
|
['{"result":1}']
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$self->logger->error("Unknown Yubikey action -> $action");
|
$self->logger->error("Unknown Yubikey action -> $action");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user