Subject: | User.pm |
has_attribute has a special case for 'dn' using the underlying ldap_entry
but the AUTOLOAD does not have this special case for 'dn'
Also AUTOLOAD has a special case for 'username' but has_attribute does not.
These two methods should have similar functionality for sanity reasons.
I attached a patch file for what I am talking about
Subject: | user.patch |
--- User.pm 2009-12-11 12:24:44.000000000 -0600
+++ /home/fried/User.pm 2010-05-18 15:59:59.000000000 -0500
@@ -226,6 +226,9 @@
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};
}
@@ -294,20 +297,9 @@
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(