[Catalyst] Legacy porting to auto-authenticate a logged in user
Peter Edwards
peter at dragonstaff.com
Sat Dec 22 11:44:14 GMT 2007
Try
$c->authenticate({ acctid => $user->username,
password => $user->password })
or die "RC_403: " . $user->username . " failed to authenticate";
Regards, Peter
-----Original Message-----
From: Ashley Pond V [mailto:apv at sedition.com]
Sent: 22 December 2007 08:08
To: The elegant MVC web framework
Subject: [Catalyst] Legacy porting to auto-authenticate a logged in user
I have what I first thought was a gimme (this is only tangentially
related to the questions I asked a few days ago; same app, different
DB and part). Legacy porting of a "login" with Authenticate where I
already have the user id and everything verified. I have tried many
permutations of arguments and setup.
The user has already logged into the legacy part of the app. So this
is the code that is not working but I think should.
my $user_id = ...legacy fetch; working fine
my $user = $c->model("DB::User")->find($user_id)
or die "RC_403: No such user for id $user_id"; # also working
fine
# this dies, I've verified the $user, username, and password are
correct
$c->authenticate({ username => $user->username,
password => $user->password })
or die "RC_403: " . $user->username . " failed to authenticate";
So. why? The legacy setup is a little strange so I think that must be
it. The user table's DBIC looks like this (password is plaintext,
legacy, and crypt_passwd is sha1 of it)-
package MyApp::DB::User;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/PK::Auto Core/);
__PACKAGE__->table('foo.account');
__PACKAGE__->add_columns(qw/ acctid email fname lname password
crypt_passwd /);
__PACKAGE__->set_primary_key('acctid');
sub username {
+shift->email;
};
My config looks like this-
authentication:
default_realm: users
realms:
users:
credential:
class: Password
password_field: crypt_passwd
password_type: hashed
password_hash_type: SHA-1
store:
class: DBIx::Class
user_class: DB::User
id_field: acctid
Thanks for looking!
-Ashley
_______________________________________________
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@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/
More information about the Catalyst
mailing list