[Catalyst] Legacy porting to auto-authenticate a logged in user

Ashley Pond V apv at sedition.com
Sat Dec 22 08:07:32 GMT 2007


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




More information about the Catalyst mailing list