Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

error when using Authentication::Store::Minimal

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


ace at tommybutler

Jun 2, 2009, 3:09 PM

Post #1 of 4 (408 views)
Permalink
error when using Authentication::Store::Minimal

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
Attachments: signature.asc (0.25 KB)


ace at tommybutler

Jun 2, 2009, 3:51 PM

Post #2 of 4 (374 views)
Permalink
Re: error when using Authentication::Store::Minimal [In reply to]

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


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


arodland at comcast

Jun 2, 2009, 4:36 PM

Post #3 of 4 (374 views)
Permalink
Re: Re: error when using Authentication::Store::Minimal [In reply to]

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


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


bobtfish at bobtfish

Jun 2, 2009, 6:17 PM

Post #4 of 4 (372 views)
Permalink
Re: Re: error when using Authentication::Store::Minimal [In reply to]

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


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

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.