use strict;
use warnings;
-our $VERSION = '0.1005';
+our $VERSION = '1.011';
use Catalyst::Authentication::Store::LDAP::User;
use Net::LDAP;
return $self;
}
-=head2 find_user( I<authinfo> )
+=head2 find_user( I<authinfo>, $c )
Creates a L<Catalyst::Authentication::Store::LDAP::User> object
for the given User ID. This is the preferred mechanism for getting a
sub find_user {
my ( $self, $authinfo, $c ) = @_;
- return $self->get_user( $authinfo->{id} || $authinfo->{username} );
+ return $self->get_user( $authinfo->{id} || $authinfo->{username}, $c );
}
-=head2 get_user($id)
+=head2 get_user( I<id>, $c)
Creates a L<Catalyst::Authentication::Store::LDAP::User> object
-for the given User ID. This is the preferred mechanism for getting a
-given User out of the Store.
+for the given User ID, or calls C<new> on the class specified in
+C<user_class>. This instance of the store object, the results of
+C<lookup_user> and $c are passed as arguments (in that order) to C<new>.
+This is the preferred mechanism for getting a given User out of the Store.
=cut
sub get_user {
- my ( $self, $id ) = @_;
+ my ( $self, $id, $c ) = @_;
my $user = $self->user_class->new( $self,
- $self->lookup_user($id) );
+ $self->lookup_user($id), $c );
return $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 ) ) {
}
my $usersearch = $ldap->search(@searchopts);
- return if ( $usersearch->is_error );
+ return undef if ( $usersearch->is_error );
my $userentry;
my $user_field = $self->user_field;
Catalyst::Authentication::Store::LDAP::User->supports(@_);
}
-=head2 from_session( I<id> )
+=head2 from_session( I<id>, I<$c> )
Returns get_user() for I<id>.
sub from_session {
my ( $self, $c, $id ) = @_;
- $self->get_user($id);
+ $self->get_user($id, $c);
}
1;