Skip to content

Commit

Permalink
fix user find
Browse files Browse the repository at this point in the history
  • Loading branch information
nics committed Mar 26, 2018
1 parent fb7832b commit f461270
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions lib/LibreCat/Model/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,18 @@ sub get {
# TODO clean this up
sub find {
my ($self, $id) = @_;

$id // return;

my $hits = LibreCat->searcher->search('user', {cql => ["id=$id"]});
$hits = LibreCat->searcher->search('user', {cql => ["login=$id"]})
if !$hits->{total};
return $hits->{hits}->[0] if $hits->{total};

if (my $user
= $self->get($id)
|| $self->find_by_username($id))
{
return $user;
if ($id) {
my $hits = LibreCat->searcher->search('user', {cql => ["id=$id"]});
$hits = LibreCat->searcher->search('user', {cql => ["login=$id"]})
if !$hits->{total};
return $hits->{hits}->[0] if $hits->{total};
if (my $user
= $self->get($id)
|| $self->find_by_username($id))
{
return $user;
}
}

return;
}

sub find_by_username {
Expand Down

0 comments on commit f461270

Please sign in to comment.