Append parameter test & error msg

This commit is contained in:
Christophe Maudoux 2018-08-30 19:45:35 +02:00
parent 2672fa006b
commit 095b1d2531
3 changed files with 11 additions and 3 deletions

View File

@ -268,13 +268,16 @@ sub run {
# Delete TOTP
elsif ( $action eq 'delete' ) {
my $epoch = $req->param('epoch');
# Check if unregistration is allowed
unless ( $self->conf->{totp2fUserCanRemoveKey} ) {
return $self->p->sendError( $req, 'notAuthorized', 400 );
}
my $epoch = $req->param('epoch')
or return $self->p->sendError( $req, '"epoch" parameter is missing',
400 );
# Read existing 2FDevices
$self->logger->debug("Loading 2F Devices ...");
my $_2fDevices;

View File

@ -254,7 +254,9 @@ sub run {
return $self->p->sendError( $req, 'notAuthorized', 200 );
}
my $epoch = $req->param('epoch');
my $epoch = $req->param('epoch')
or return $self->p->sendError( $req, '"epoch" parameter is missing',
400 );
# Read existing 2FDevices
$self->logger->debug("Looking for 2F Devices ...");

View File

@ -137,13 +137,16 @@ sub run {
}
elsif ( $action eq 'delete' ) {
my $epoch = $req->param('epoch');
# Check if unregistration is allowed
unless ( $self->conf->{yubikey2fUserCanRemoveKey} ) {
return $self->p->sendError( $req, 'notAuthorized', 400 );
}
my $epoch = $req->param('epoch')
or return $self->p->sendError( $req, '"epoch" parameter is missing',
400 );
# Read existing 2FDevices
$self->logger->debug("Looking for 2F Devices ...");
my $_2fDevices;