<div>Hi Tomas,</div><div><br></div><div> I got carried away with the other work for the same app. Now I'm back to this point again. </div><div><br></div><div>I created a file called User.pm and put it under Model directory. </div>
<div>After putting, use base "Catalyst::Authentication::Store::Htpasswd::User"; I am trying to use around find_user or any method that is present in the base class but I ended up getting following error.</div>
<div><br></div><div>"Couldn't load class (MyApp) because: The method 'check_password' was not found in the inheritance hierarchy."</div><div><br></div><div>I'm sorry to ask you again but I'm not sure how the following subclassing can be done.</div>
<div><br></div><div>Could you send few more details ( example) ?</div><div><br></div><div>====</div><div><div>package MyApp::Model::User;</div><div>use Moose;</div><div>use namespace::autoclean;</div><div>use Switch;</div>
<div>use base "Catalyst::Authentication::Store::Htpasswd::User";</div><div>extends 'Catalyst::Model';</div><div><br></div><div><br></div><div>around check_password => sub {</div><div> my ($orig, $self, $authinfo, $c, @args) = @_;</div>
<div> my $user = $self->$orig($authinfo, $c, @args);</div><div> return $user;</div><div>};</div></div><div><br></div><div>OR</div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">around find_user => sub {<br>
my ($orig, $self, $authinfo, $c, @args) = @_;<br> my $user = $self->$orig($authinfo, $c, @args);<br> $user->extra_field($c->model('DB::User')->find({ username => $user->id })->first->extra_field;<br>
return $user;<br>};</span></div><div>====</div><div><br></div><div>Thanks,</div><div>Rohan</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br><div class="gmail_quote">On Sat, May 7, 2011 at 9:00 PM, Tomas Doran <span dir="ltr"><<a href="mailto:bobtfish@bobtfish.net">bobtfish@bobtfish.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"><br>
On 7 May 2011, at 14:29, Rohan M wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Yes. Now the Authentication part is working.<br>
<br>
I'm running into one more issue. Now, I'm able to get username from the htpasswd file. But my user information like Name, Address is stored in the database.<br>
<br>
Can I add this information (name, address coming from db) in the user object generated from Catalyst::Authentication::Store::Htpasswd ?<br>
<br>
Does anyone has idea how to go about this?<br>
</blockquote>
<br>
<br>
</div><a href="http://search.cpan.org/~bobtfish/Catalyst-Authentication-Store-Htpasswd-1.003/lib/Catalyst/Authentication/Store/Htpasswd.pm#user_class" target="_blank">http://search.cpan.org/~bobtfish/Catalyst-Authentication-Store-Htpasswd-1.003/lib/Catalyst/Authentication/Store/Htpasswd.pm#user_class</a><br>
<br>
I.e. subclass Catalyst::Authentication::Store::Htpasswd::User as MyApp::User, change that config setting, and you can now put extra code into your user class...<br>
<br>
This gets your part way, but you don't have $c here, so your user class can't lookup the extra info in the app..<br>
<br>
The solution to that is to also subclass the Store itself, and wrap / use an around method modifier on the 'find_user' method - something like (in pseudocode):<br>
<br>
around find_user => sub {<br>
my ($orig, $self, $authinfo, $c, @args) = @_;<br>
my $user = $self->$orig($authinfo, $c, @args);<br>
$user->extra_field($c->model('DB::User')->find({ username => $user->id })->first->extra_field;<br>
return $user;<br>
};<br>
<br>
Sane error handling (e.g. user does not exist, or user in the htpasswd file, but not the DB) is left as an exercise for the reader.<div><div></div><div class="h5"><br>
<br>
Cheers<br>
t0m<br>
<br>
<br>
_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
</div></div></blockquote></div><br><div><span style="line-height:32px;font-size:large"><br></span></div><br>
</div>