[Catalyst] moving from Auth::Store::DBIC to Auth::Store::DBIx::Class

Fernan Aguero fernan.aguero at gmail.com
Thu Apr 1 20:42:02 GMT 2010


Hi,

after reading lots of warnings in our logs about
Authentication::Store::DBIC being deprecated, I thought about devoting
some time to move to its replacement,
Authentication::Store::DBIx::Class, but upon starting to work on this
I've also started to hit on some problems.

So, my first question to the list would be about the availability of a
guide of things to look for, other incompatble plugins, etc.

I presume others have already made the switch ...

Now, basically, I'm trying to move from (old code, using Auth::Store::DBIC):

this is my lib/app.pm:
use Catalyst qw/
 ConfigLoader
 Static::Simple
 Session
 Session::PerUser
 Session::Store::DBIC
 Session::State::Cookie
 Authentication
 Authentication::Store::DBIC
 Authentication::Credential::Password
 Authorization::Roles
 Params::Nested
 StackTrace
 Scheduler
 Captcha
 -Debug
/;

and this is my app.yml configuration file:
 authentication:
 dbic:
  user_class: weight::Users
  user_field: username
  password_field: password
  password_type: hashed
  password_hash_type: MD5
  session_data_field: session_data

 authorization:
  dbic:
    role_class: weight::Roles
    role_field: role
    role_rel: map_user_role
    user_role_user_field: userid


which was working fine, to the following:


this is my attempt at updating lib/app.pm (removed two lines):
use Catalyst qw/
 ConfigLoader
 Static::Simple
 Session
 Session::PerUser
 Session::Store::DBIC
 Session::State::Cookie
 Authentication
 Authorization::Roles
 Params::Nested
 StackTrace
 Scheduler
 Captcha
 -Debug
 /;

app.yml (reorganized based on SYNOPSIS of Auth::Store::DBIx::Class):
authentication:
 default_realm: users
 realms:
 users:
  credential:
   class: Password
   password_field: password
   password_type: hashed
   password_hash_type: MD5
  store:
   class: DBIx::Class
   user_model: weight::Users
   role_relation: roles
   role_field: role
   session_data_field: session_data

The built-in server starts up OK, and works OK (session works, our
cart-like history functionality works) but upon login I get some
errors, from subs imported from Session::PerUser I guess (I'm
overriding the merge_session_to_user sub to do some more intelligent
merging of the items in the user's history).

However if I comment out that section I still get this:

Caught exception in portfolio::Controller::user->login "Can't locate
object method "user" via package
"Catalyst::Plugin::Session::Store::DBIC::Delegate" at
/usr/local/share/perl/5.10.0/Catalyst/Plugin/Session/Store/DBIC.pm
line 181."

Stack Trace

Package Line    File
portfolio::Controller::user     42      /home/fernan/lib/app/Controller/user.pm
  39:          if ( $username && $password ) {
  40:
  41:                          # attempt to login
  42:                          if ( $c->authenticate(
  43:                                          { username =>
$username, password => $password },
  44:                                          'users'
  45:                                  ) ) {

I can certainly provide more details on the code, but at this moment I
started to think that maybe
Catalyst::Plugin::Session::Store::DBIC::Delegate is incompatible with
Catalyst::Authentication::Store::DBIx::Class?

Thanks in advance for any help on this.

Cheers,


-- 
fernan



More information about the Catalyst mailing list