FAQ
Skipped content of type multipart/alternative-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090602/ab0bf9c9/signature.pgp

Search Discussions

  • Tommy Butler at Jun 2, 2009 at 10:51 pm
    I found my own answer by looking at the source code for the MVC plugin.
    So much for the book.

    The login method expects two strings: a username and a password. Kudos
    to the author who also made the method able to detect a username and
    password based on best-guess, common sense logic of what they MIGHT be
    based on the $c->request form parameter input. Sadly, this was still no
    match for the misinformation I was up against. The login method doesn't
    want a hashref at all, as we observe here in the source:

    http://cpansearch.perl.org/src/JROBINSON/Catalyst-Plugin-Authentication-0.10007_01/lib/Catalyst/Authentication/Credential/Password.pm

    Tommy Butler wrote:
    Could anyone provide some insight on why this might be failing? I'm
    trying to use Authentication::Store::Minimal just to test
    authentication, following along with the examples in the Catalyst book
    by Jon Rockway.

    $c->login continues to fail. Instead I get this error from the debug
    server: [debug] User 'HASH(0x2460d20)' doesn't exist in the default
    store.

    My login controller's relevant code is thus:

    \\\\\\\\\\\ start code >

    sub index : Private {
    my ( $self, $c ) = @_;

    my $username = $c->request->param('username') || '';
    my $password = $c->request->param('password') || '';

    if ($username && $password) {
    # attempt to log user in
    if ($c->login({
    username => $username,
    password => $password,
    })) {
    $c->response->redirect($c->uri_for('/portal'));
    return
    }
    else {
    # set an error message
    $c->stash->{error} = 'Bad username or password';
    }
    }

    # if either of the above don't work out, send back to login page
    $c->stash->{message} .= 'Welcome, User. Please Log In.';
    $c->stash->{username} = $c->request->param('username');
    $c->stash->{template} = 'login.tt';
    }

    /////////// < end code

    I am expecting that my login would succeed, but this is not the case.
    Bear in mind that Sessions appear to be working perfectly.

    Any insights? The relevant parts of my primary application file is as
    shown below:

    \\\\\\\\\\\ start code >

    use Catalyst qw/
    -Debug
    ConfigLoader
    Static::Simple

    StackTrace

    Session
    Session::State::Cookie
    Session::Store::DBIC

    Authentication
    Authentication::Store::Minimal
    Authentication::Credential::Password
    /;

    our $VERSION = '0.01';

    __PACKAGE__->config( name => 'ABCweb' );

    __PACKAGE__->config(
    session => {
    flash_to_stash => 1,
    dbic_class => 'DB::Sessions',
    },
    );

    __PACKAGE__->config->{authentication}{users} = {
    'tommy' => {
    password => 'password'
    }
    };

    /////////// < end code
  • Andrew Rodland at Jun 2, 2009 at 11:36 pm
    You shouldn't be using the login method to begin with, you want authenticate.
    Pay less attention to the book (which has very little to do with anything) and
    more to the docs.

    Andrew
  • Tomas Doran at Jun 3, 2009 at 1:17 am

    On 2 Jun 2009, at 23:51, Tommy Butler wrote:

    I found my own answer by looking at the source code for the MVC
    plugin.
    The MVC plugin? Huh? You mean the authentication plugin?

    So much for the book.
    Yeah, the book hasn't aged well, which is unfortunate.

    http://dev.catalyst.perl.org/wiki/TheBookErrata
    http://cpansearch.perl.org/src/JROBINSON/Catalyst-Plugin-
    Authentication-0.10007_01/lib/Catalyst/Authentication/Credential/
    Password.pm
    Note that you're looking at the docs and source code for a
    development release which is a year old here..

    Cheers
    t0m

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJun 2, '09 at 10:08p
activeJun 3, '09 at 1:17a
posts4
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase