<div>Hi Tomas,</div><div><br></div><div> I got carried away with the other work for the same app. Now I&#39;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 &quot;Catalyst::Authentication::Store::Htpasswd::User&quot;;  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>&quot;Couldn&#39;t load class (MyApp) because: The method &#39;check_password&#39; was not found in the inheritance hierarchy.&quot;</div><div><br></div><div>I&#39;m sorry to ask you again but I&#39;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 &quot;Catalyst::Authentication::Store::Htpasswd::User&quot;;</div><div>extends &#39;Catalyst::Model&#39;;</div><div><br></div><div><br></div><div>around check_password =&gt; sub {</div><div>   my ($orig, $self, $authinfo, $c, @args) = @_;</div>
<div>   my $user = $self-&gt;$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 =&gt; sub {<br>
   my ($orig, $self, $authinfo, $c, @args) = @_;<br>   my $user = $self-&gt;$orig($authinfo, $c, @args);<br>   $user-&gt;extra_field($c-&gt;model(&#39;DB::User&#39;)-&gt;find({ username =&gt; $user-&gt;id })-&gt;first-&gt;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">&lt;<a href="mailto:bobtfish@bobtfish.net">bobtfish@bobtfish.net</a>&gt;</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&#39;m running into one more issue. Now, I&#39;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&#39;t have $c here, so your user class can&#39;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 &#39;find_user&#39; method - something like (in pseudocode):<br>
<br>
around find_user =&gt; sub {<br>
    my ($orig, $self, $authinfo, $c, @args) = @_;<br>
    my $user = $self-&gt;$orig($authinfo, $c, @args);<br>
    $user-&gt;extra_field($c-&gt;model(&#39;DB::User&#39;)-&gt;find({ username =&gt; $user-&gt;id })-&gt;first-&gt;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>