Pass $c along to find_user method so overridden user_class users can get at models...
Cory G Watson [Fri, 15 May 2009 20:25:36 +0000 (20:25 +0000)]
Changes
lib/Catalyst/Authentication/Store/LDAP/Backend.pm
lib/Catalyst/Authentication/Store/LDAP/User.pm

diff --git a/Changes b/Changes
index d7402ea..a591102 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,7 @@
+0.1006
+   - Pass $c along to find_user method so overridden user_class users can
+     get at models (or whatever crazy things they might do) (gphat)
+
 0.1005  30 April 2009
    - Stop throwing an exception when the lookup_user method fails
       to find a user and instead return undef. (t0m)
index 80aad95..e562977 100644 (file)
@@ -129,7 +129,7 @@ sub new {
     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 
@@ -142,21 +142,23 @@ C<username>. The value will be compared against the LDAP C<user_field> field.
 
 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)
 
 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;
 }
 
index 219576e..559ba16 100644 (file)
@@ -57,18 +57,20 @@ use overload '""' => sub { shift->stringify }, fallback => 1;
 
 =head1 METHODS
 
-=head2 new($store, $user)
+=head2 new($store, $user, $c)
 
 Takes a L<Catalyst::Authentication::Store::LDAP::Backend> object
 as $store, and the data structure returned by that class's "get_user"
-method as $user.
+method as $user.  The final argument is an instance of your application,
+which is passed along for those wanting to subclass User and perhaps use
+models for fetching data.
 
 Returns a L<Catalyst::Authentication::Store::LDAP::User> object.
 
 =cut
 
 sub new {
-    my ( $class, $store, $user ) = @_;
+    my ( $class, $store, $user, $c ) = @_;
 
     return unless $user;