Allow multi-valued excluding parameters (#1976)
This commit is contained in:
parent
fc6ea96954
commit
554daba5fe
|
@ -85,29 +85,28 @@ sub provideUser {
|
|||
sub retreiveFindUserParams {
|
||||
my ( $self, $req ) = @_;
|
||||
my ( $searching, $excluding ) = ( [], [] );
|
||||
|
||||
$self->logger->debug("FindUser: reading parameters...");
|
||||
foreach ( sort keys %{ $self->conf->{findUserSearchingAttributes} } ) {
|
||||
@$searching = map {
|
||||
my $param = $req->params($_) // '';
|
||||
if ( $param =~ /.+/ ) {
|
||||
$self->logger->debug(
|
||||
"Pushing searching parameter: $_ => $param" );
|
||||
push @$searching, { key => $_, value => $param };
|
||||
}
|
||||
}
|
||||
$self->logger->debug("Push searching parameter: $_ => $param")
|
||||
if $param =~ /.+/;
|
||||
$param =~ /.+/ ? { key => $_, value => $param } : ();
|
||||
} sort keys %{ $self->conf->{findUserSearchingAttributes} };
|
||||
|
||||
if ( scalar @$searching
|
||||
&& keys %{ $self->conf->{findUserExcludingAttributes} } )
|
||||
{
|
||||
$self->logger->debug("FindUser: reading excluding parameters...");
|
||||
foreach ( sort keys %{ $self->conf->{findUserExcludingAttributes} } ) {
|
||||
$self->logger->debug( "Pushing excluding parameter: $_ => "
|
||||
. $self->conf->{findUserExcludingAttributes}->{$_} );
|
||||
push @$excluding,
|
||||
{
|
||||
key => $_,
|
||||
value => $self->conf->{findUserExcludingAttributes}->{$_}
|
||||
};
|
||||
}
|
||||
@$excluding = map {
|
||||
my $key = $_;
|
||||
map {
|
||||
$self->logger->debug("Push excluding parameter: $key => $_");
|
||||
{ key => $key,
|
||||
value => $_ } # Allow multivalued excluding parameters
|
||||
} split $self->conf->{multiValuesSeparator},
|
||||
$self->conf->{findUserExcludingAttributes}->{$_};
|
||||
} sort keys %{ $self->conf->{findUserExcludingAttributes} };
|
||||
}
|
||||
|
||||
return ( $searching, $excluding );
|
||||
|
|
|
@ -33,6 +33,9 @@ SKIP: {
|
|||
"INSERT INTO users VALUES ('msmith','msmith','Mr Smith','character','good','0')"
|
||||
);
|
||||
$dbh->do(
|
||||
"INSERT INTO users VALUES ('davrosjr','davrosjr','Davros Junior','character','bad','0')"
|
||||
);
|
||||
$dbh->do(
|
||||
"INSERT INTO users VALUES ('dalek','dalek', 'The Daleks','mutant','bad','1')"
|
||||
);
|
||||
my $client = LLNG::Manager::Test->new( {
|
||||
|
@ -41,6 +44,7 @@ SKIP: {
|
|||
authentication => 'DBI',
|
||||
userDB => 'Same',
|
||||
dbiAuthChain => "dbi:SQLite:dbname=$userdb",
|
||||
multiValuesSeparator => ' # ',
|
||||
dbiAuthUser => '',
|
||||
dbiAuthPassword => '',
|
||||
dbiAuthTable => 'users',
|
||||
|
@ -59,7 +63,7 @@ SKIP: {
|
|||
room => 'Room'
|
||||
},
|
||||
findUserExcludingAttributes =>
|
||||
{ type => 'mutant', uid => 'rtyler' },
|
||||
{ type => 'mutant', uid => 'rtyler # davrosjr # ' },
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user