FAQ
Yes. Now the Authentication part is working.

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.

Can I add this information (name, address coming from db) in the user object
generated from Catalyst::Authentication::Store::Htpasswd ?

Does anyone has idea how to go about this?


---------- Forwarded message ----------
From: Rohan M <rohan7799@gmail.com>
Date: Mon, May 2, 2011 at 5:20 PM
Subject: Re: [Catalyst] Re: Using htpasswd file.
To: The elegant MVC web framework <catalyst@lists.scsys.co.uk>


Yes Tomas, you are right. I was using CPAN to install
Catalyst::Plugin::Authentication module. But when I checked it manually the
pm file was absent and even the upgrade command in CPAN was showing that the
Module is upto date. So I thought the file would be there .. My bad ..
Sorry for that..

Yes. Now the Authentication part is working.

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.

Can I add this information (name, address coming from db) in the user object
generated from Catalyst::Authentication::Store::Htpasswd ?

Thanks for your help.

Regards,
Rohan
On Fri, Apr 29, 2011 at 8:57 PM, Tomas Doran wrote:


On 25 Apr 2011, at 09:54, Rohan M wrote:

Catalyst::Plugin::Authentication::Store::Htpasswd
Erm, I don't know why this is being loaded / used.

You want Catalyst::Authentication::Store::Htpasswd

Can you confirm that module is installed?

Cheers
t0m


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/






--
रोहन मल�लेल�रवार
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110507/11747798/attachment.htm

Search Discussions

  • Tomas Doran at May 7, 2011 at 3:30 pm

    On 7 May 2011, at 14:29, Rohan M wrote:

    Yes. Now the Authentication part is working.

    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.

    Can I add this information (name, address coming from db) in the
    user object generated from Catalyst::Authentication::Store::Htpasswd ?

    Does anyone has idea how to go about this?

    http://search.cpan.org/~bobtfish/Catalyst-Authentication-Store-Htpasswd-1.003/lib/Catalyst/Authentication/Store/Htpasswd.pm#user_class

    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...

    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..

    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):

    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;
    };

    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.

    Cheers
    t0m
  • Rohan M at May 30, 2011 at 3:27 pm
    Hi Tomas,

    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;
    };
    ====

    Thanks,
    Rohan
    On Sat, May 7, 2011 at 9:00 PM, Tomas Doran wrote:


    On 7 May 2011, at 14:29, Rohan M wrote:

    Yes. Now the Authentication part is working.
    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.

    Can I add this information (name, address coming from db) in the user
    object generated from Catalyst::Authentication::Store::Htpasswd ?

    Does anyone has idea how to go about this?


    http://search.cpan.org/~bobtfish/Catalyst-Authentication-Store-Htpasswd-1.003/lib/Catalyst/Authentication/Store/Htpasswd.pm#user_class

    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...

    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..

    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):

    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;
    };

    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.


    Cheers
    t0m


    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110530/7fb5b0e8/attachment.htm
  • John Romkey at May 31, 2011 at 1:32 am

    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
  • Rohan M at May 31, 2011 at 9:40 am
    Hi John,

    I'll give a try and post it after the successful run. Meanwhile, a
    workaround , I used session to store db object for the user and used it.

    thanks for the guidance..

    Regards,
    ROhan
    On Tue, May 31, 2011 at 7:02 AM, John Romkey wrote:

    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/



    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110531/a51b68aa/attachment.htm

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedMay 7, '11 at 1:29p
activeMay 31, '11 at 9:40a
posts5
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase