X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAuthentication%2FStore%2FLDAP%2FUser.pm;h=42e44174dc575a6bd6ff66f4c1bef8add8a28018;hb=57d476f11c5e55a1d39c6f5b5ac56ab31e2d9226;hp=fb00a4e52e8b59dd53b7465b5f5c2e2e4b2f63ae;hpb=5faab354ecbab92761e17e5c50d5d38a0b0b6845;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 fb00a4e..42e4417 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.009'; +our $VERSION = '1.012'; BEGIN { __PACKAGE__->mk_accessors(qw/user store/) } @@ -228,6 +228,9 @@ sub has_attribute { if ( $attribute eq "dn" ) { return $self->ldap_entry->dn; } + elsif ( $attribute eq "username" ) { + return $self->user->{'attributes'}->{$self->store->user_field}; + } elsif ( exists( $self->user->{'attributes'}->{$attribute} ) ) { return $self->user->{'attributes'}->{$attribute}; } @@ -236,6 +239,23 @@ sub has_attribute { } } +=head2 get + +A simple wrapper around has_attribute() to satisfy the Catalyst::Authentication::User API. + +=cut + +sub get { return shift->has_attribute(@_) } + +=head2 get_object + +Satisfies the Catalyst::Authentication::User API and returns the contents of the user() +attribute. + +=cut + +sub get_object { return shift->user } + =head2 ldap_connection Re-binds to the auth store with the credentials of the user you logged in @@ -302,20 +322,9 @@ sub AUTOLOAD { if ( $method eq "DESTROY" ) { return; } - if ( exists( $self->user->{'attributes'}->{$method} ) ) { - return $self->user->{'attributes'}->{$method}; - } - elsif ( $method eq "username" ) { - my $userfield = $self->store->user_field; - my $username = $self->has_attribute($userfield); - if ($username) { - return $username; - } - else { - Catalyst::Exception->throw( "User is missing the " - . $userfield - . " attribute, which should not be possible!" ); - } + + if ( my $attribute = $self->has_attribute($method) ) { + return $attribute; } else { Catalyst::Exception->throw(