[Catalyst] Re: Using htpasswd file : New Issue
John Romkey
romkey at romkey.com
Tue May 31 01:32:34 GMT 2011
On May 30, 2011, at 11:27 AM, Rohan M wrote:
> I got carried away with the other work for the same app. Now I'm back to this point again.
>
> I created a file called User.pm and put it under Model directory.
> 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.
>
> "Couldn't load class (MyApp) because: The method 'check_password' was not found in the inheritance hierarchy."
>
> I'm sorry to ask you again but I'm not sure how the following subclassing can be done.
>
> Could you send few more details ( example) ?
>
> ====
> package MyApp::Model::User;
> use Moose;
> use namespace::autoclean;
> use Switch;
> use base "Catalyst::Authentication::Store::Htpasswd::User";
> extends 'Catalyst::Model';
>
>
> around check_password => sub {
> my ($orig, $self, $authinfo, $c, @args) = @_;
> my $user = $self->$orig($authinfo, $c, @args);
> return $user;
> };
>
> OR
>
> around find_user => sub {
> my ($orig, $self, $authinfo, $c, @args) = @_;
> my $user = $self->$orig($authinfo, $c, @args);
> $user->extra_field($c->model('DB::User')->find({ username => $user->id })->first->extra_field;
> return $user;
> };
Rohan,
I haven't verified this but I think that what you want to do is make it be a regular class, not a Catalyst component. Then in your configuration where you specify your user_class for your store use MyApp::User rather than Catalyst::Authentication::Store::Htpasswd::User
package MyApp::User;
use Moose;
use namespace::autoclean;
extends 'Catalyst::Authentication::Store::Htpasswd::User';
around check_password => sub {
my ($orig, $self, $authinfo, $c, @args) = @_;
my $user = $self->$orig($authinfo, $c, @args);
return $user;
};
around find_user => sub {
my ($orig, $self, $authinfo, $c, @args) = @_;
my $user = $self->$orig($authinfo, $c, @args);
$user->extra_field($c->model('DB::User')->find({ username => $user->id })->first->extra_field;
return $user;
};
- john romkey
http://www.romkey.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110530/2179fe3f/attachment.htm
More information about the Catalyst
mailing list