From: Cory G Watson Date: Fri, 15 May 2009 20:25:36 +0000 (+0000) Subject: Pass $c along to find_user method so overridden user_class users can get at models... X-Git-Tag: v0.1006~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=52a972a4846d22d327aee1ec6c0c5e76e216cb58;p=catagits%2FCatalyst-Authentication-Store-LDAP.git Pass $c along to find_user method so overridden user_class users can get at models (or whatever crazy things they might do) --- diff --git a/Changes b/Changes index d7402ea..a591102 100644 --- 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) diff --git a/lib/Catalyst/Authentication/Store/LDAP/Backend.pm b/lib/Catalyst/Authentication/Store/LDAP/Backend.pm index 80aad95..e562977 100644 --- a/lib/Catalyst/Authentication/Store/LDAP/Backend.pm +++ b/lib/Catalyst/Authentication/Store/LDAP/Backend.pm @@ -129,7 +129,7 @@ sub new { return $self; } -=head2 find_user( I ) +=head2 find_user( I, $c ) Creates a L object for the given User ID. This is the preferred mechanism for getting a @@ -142,21 +142,23 @@ C. The value will be compared against the LDAP C 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 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 on the class specified in +C. This instance of the store object, the results of +C and $c are passed as arguments (in that order) to C. +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; } diff --git a/lib/Catalyst/Authentication/Store/LDAP/User.pm b/lib/Catalyst/Authentication/Store/LDAP/User.pm index 219576e..559ba16 100644 --- a/lib/Catalyst/Authentication/Store/LDAP/User.pm +++ b/lib/Catalyst/Authentication/Store/LDAP/User.pm @@ -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 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 object. =cut sub new { - my ( $class, $store, $user ) = @_; + my ( $class, $store, $user, $c ) = @_; return unless $user;