Commits (4)
......@@ -19,7 +19,7 @@ Just enable it in the Manager (section “plugins”). Then, set searching attri
- **Character used as wildcard**: Character that can be used by users as wildcard. An empty value disable wildcarded search requests
- **Parameters control**: Regular expression used for checking searching values syntax
- **User accounts URL**: User database URL to search on if REST backend is used. Let it blank to use default user data URL.
- **Searching attributes**: For each attribute, you have to set a key (attribute as defined in UserBD) and a value that will be display in login form (placeholder). A value can be a multivalued list separated by multiValuesSeparator parameter (General Parameters > Advanced parameters > Separator). See note below.
- **Searching attributes**: For each attribute, you have to set a key (attribute as defined in UserBD) and a value that will be display in login form (placeholder). A value can be a multivalued list separated by multiValuesSeparator parameter (General Parameters > Advanced parameters > Separator). Attibutes can be sorted by adding ``#_`` before their name (where ``#`` is a number). See note below.
- **Excluding attributes**: You can defined here attributes used for excluding accounts. Set keys corresponding to UserBD attributes and values to exclude. A value can be a multivalued list separated by multiValuesSeparator parameter (General Parameters > Advanced parameters > Separator)
.. note::
......@@ -41,7 +41,9 @@ Just enable it in the Manager (section “plugins”). Then, set searching attri
uid#Identity#1 => dwho; Dr Who; rtyler; Rose Tyler (allow empty value)
Entries are sorted by alphabetical order.
1_uid#Identity#1 => 2_dwho; Dr Who; 1_rtyler; Rose Tyler; dalek; Dalek
(The attributes will be sorted by number, those without a number will appear at the end of the list)
.. attention::
......
......@@ -9,7 +9,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
PE_TOKENEXPIRED
);
our $VERSION = '2.0.13';
our $VERSION = '2.0.14';
extends qw(
Lemonldap::NG::Portal::Main::Plugin
......@@ -80,9 +80,10 @@ sub retreiveFindUserParams {
$self->logger->debug("FindUser: reading parameters...");
@$searching = map {
my ( $key, $value, $null ) = split '#', $_;
$key =~ s/^(?:\d+_)?//;
my $param = $req->params($key) // '';
my @values = split $self->conf->{multiValuesSeparator},
$self->conf->{findUserSearchingAttributes}->{$_} || '';
my @values = grep s/^(?:\d+_)?//, split ($self->conf->{multiValuesSeparator},
$self->conf->{findUserSearchingAttributes}->{$_} || '');
my $select = scalar @values > 1 && not scalar @values % 2;
my %values = @values if $select;
my $defined = length $param;
......@@ -150,11 +151,11 @@ sub buildForm {
$self->logger->debug('Building array ref with searching fields...');
@$fields =
sort { $a->{select} <=> $b->{select} || $a->{value} cmp $b->{value} }
map {
my ( $key, $value, $null ) = split '#', $_;
my @values = split $self->conf->{multiValuesSeparator},
$self->conf->{findUserSearchingAttributes}->{$_} || $key;
$key =~ s/^(?:\d+_)?//;
my $nbr = scalar @values;
if ( $nbr > 1 ) {
if ( $nbr % 2 ) { () }
......@@ -164,8 +165,11 @@ sub buildForm {
$nbr /= 2;
$self->logger->debug(
"Building $key with type 'select' and $nbr entries...");
@$choices = sort { $a->{value} cmp $b->{value} }
map { { key => $_, value => $hash{$_} } } keys %hash;
@$choices = map {
my $k = $_;
$k =~ s/^(?:\d+_)?//;
{ key => $k, value => $hash{$_} }
} sort keys %hash;
{
select => 1,
key => $key,
......@@ -182,7 +186,7 @@ sub buildForm {
value => $values[0]
};
}
} keys %{ $self->conf->{findUserSearchingAttributes} };
} sort keys %{ $self->conf->{findUserSearchingAttributes} };
return $fields;
}
......
......@@ -31,12 +31,12 @@
<TMPL_ELSE>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text"><label for="<TMPL_VAR NAME="key">" class="mb-0"><i class="fa fa-binoculars"></i></label></span>
<input id="findUser_<TMPL_VAR NAME="key">" name="<TMPL_VAR NAME="key">" type="text" autocomplete="off" class="form-control" placeholder="<TMPL_VAR NAME="value">" />
<span class="input-group-text clear-finduser-field"><i class="fa fa-eraser"></i></span>
</div>
</div>
</TMPL_IF>
</br>
</TMPL_LOOP>
</div>
<div class="modal-footer justify-content-between">
......
......@@ -58,10 +58,10 @@ SKIP: {
findUserWildcard => '#',
impersonationRule => 1,
findUserSearchingAttributes => {
'uid##1' => 'Login',
'guy##1' => 'Kind',
'cn##1' => 'Name',
'room##1' => 'Room'
'uid##1' => 'Login',
'1_guy##1' => 'Kind',
'2_cn##1' => 'Name',
'3_room##1' => 'Room'
},
findUserExcludingAttributes =>
{ type => 'mutant', uid => 'rtyler # davrosjr # ' },
......@@ -134,6 +134,15 @@ m%<input id="findUser_room" name="room" type="text" autocomplete="off" class="fo
'id="findUser_room"'
) or explain( $res->[2]->[0], 'id="findUser_room"' );
my @c = ( $res->[2]->[0] =~ m%<input id="findUser_(\w+)"%gs );
ok( @c == 4, ' -> Four entries found' )
or explain( $res->[2]->[0], '4, found ' . scalar @c );
ok( $c[0] eq 'guy', '1st -> guy' );
ok( $c[1] eq 'cn', '2nd -> cn' );
ok( $c[2] eq 'room', '3rd -> room' );
ok( $c[3] eq 'uid', '4th -> uid' );
count(5);
$request = 'uid=dwho';
ok(
$res = $client->_post(
......
......@@ -23,8 +23,8 @@ my $client = LLNG::Manager::Test->new( {
findUserWildcard => '*',
findUserSearchingAttributes => {
'uid#fdgd#1' => undef,
'guy##1' => 'Kind',
'cn#Name#1' => 'Bad Guy; Not a good person; BB; Bad Boy'
'1_guy##1' => 'Kind',
'cn#Name#1' => 'Bad Guy; Not a good person; 2_BB; Bad Boy'
},
findUserExcludingAttributes =>
{ type => 'mutant', uid => 'rtyler' },
......