Fix bug that results in you getting the user back as your object
[catagits/Catalyst-Authentication-Store-LDAP.git] / lib / Catalyst / Authentication / Store / LDAP / Backend.pm
index e562977..e8f29c9 100644 (file)
@@ -279,6 +279,8 @@ sub lookup_user {
     if ( $id =~ /\*/ ) {
         Catalyst::Exception->throw("ID $id contains wildcards!");
     }
+    # Trim trailing space or we confuse ourselves
+    $id =~ s/\s+$//;
     my $ldap = $self->ldap_bind;
     my @searchopts;
     if ( defined( $self->user_basedn ) ) {
@@ -296,7 +298,7 @@ sub lookup_user {
     }
     my $usersearch = $ldap->search(@searchopts);
 
-    return if ( $usersearch->is_error );
+    return undef if ( $usersearch->is_error );
 
     my $userentry;
     my $user_field     = $self->user_field;