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