X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAuthentication%2FStore%2FLDAP%2FUser.pm;h=3dc1a78ded3ab31dbdf04015a044f116100cb050;hb=dfead577d0091c13ab636431aefca08d0ff7330b;hp=42e44174dc575a6bd6ff66f4c1bef8add8a28018;hpb=57d476f11c5e55a1d39c6f5b5ac56ab31e2d9226;p=catagits%2FCatalyst-Authentication-Store-LDAP.git diff --git a/lib/Catalyst/Authentication/Store/LDAP/User.pm b/lib/Catalyst/Authentication/Store/LDAP/User.pm index 42e4417..3dc1a78 100644 --- a/lib/Catalyst/Authentication/Store/LDAP/User.pm +++ b/lib/Catalyst/Authentication/Store/LDAP/User.pm @@ -50,7 +50,7 @@ use strict; use warnings; use Scalar::Util qw/refaddr/; -our $VERSION = '1.012'; +our $VERSION = '1.015'; BEGIN { __PACKAGE__->mk_accessors(qw/user store/) } @@ -140,16 +140,7 @@ bind, 0 on failure. sub check_password { my ( $self, $password ) = @_; - my $ldap - = $self->store->ldap_bind( undef, $self->ldap_entry->dn, $password, - 'forauth' ); - if ( defined($ldap) ) { - if ($self->store->role_search_as_user) { - # FIXME - This can be removed and made to use the code below.. - # Have to do the role lookup _now_, as this is the only time - # that we have the user's password/ldap bind.. - $self->roles($ldap); - } + if ( $self->store->ldap_auth($self->ldap_entry->dn, $password) ) { # Stash a closure which can be used to retrieve the connection in the users context later. $_ldap_connection_passwords{refaddr($self)} = $password; return 1; @@ -167,8 +158,7 @@ Returns the results of L's "look sub roles { my $self = shift; - my $ldap = shift; - $self->{_roles} ||= [$self->store->lookup_roles($self, $ldap)]; + $self->{_roles} ||= [$self->store->lookup_roles($self)]; return @{$self->{_roles}}; } @@ -314,6 +304,15 @@ sub DESTROY { delete $_ldap_connection_passwords{refaddr($self)}; } +sub can { + my ($self, $method) = @_; + + return $self->SUPER::can($method) || do { + return unless $self->has_attribute($method); + return sub { $_[0]->has_attribute($method) }; + }; +} + sub AUTOLOAD { my $self = shift;