[Catalyst] Catalyst::Authentication::Store::DBIx::Class upgrade - authentication fails

Anthony Gladdish a.j.gladdish at newcastle.ac.uk
Thu Nov 11 15:19:48 GMT 2010


Hi,

Upgrading Catalyst::Authentication::Store::DBIx::Class 0.1083 to 0.1200+, I get error:

" u2: , Can't call method "can" on an undefined value at /opt/netskills/apps/lib/perl5/site_perl/5.8.8/Catalyst/Authentication/Store/DBIx/Class/User.pm line 261.".


1. My yaml config:

authentication:
    default_realm:  'users'
    realms:
        users: 
            credential:
                class: 'Password'
                password_type: 'self_check'
            store:
                class: N::E2::Core::Person'
                user_model: 'E2::Person'


2. Catalyst::Authentication::Store:: N::E2::Core::Person

package Catalyst::Authentication::Store:: N::E2::Core::Person;
use strict;
use warnings;
use base qw/Catalyst::Authentication::Store::DBIx::Class/;
our $VERSION= "0.01";

sub new {
    my ( $class, $config, $app ) = @_;
    $config->{user_class}       = 'E2::Person';
    $config->{store_user_class} = 'Catalyst::Authentication::Store::N::E2::Core::Person::User';
    $config->{role_relation}    = 'authactions';
    $config->{role_field}       = 'name';
    return $class->SUPER::new( $config, $app );
}
__PACKAGE__;
__END__


3. Catalyst::Authentication::Store:: N::E2::Core::Person::User

package Catalyst::Authentication::Store:: N::E2::Core::Person::User;
use strict;
use warnings;
use base qw/Catalyst::Authentication::Store::DBIx::Class::User/;
use base qw/Class::Accessor::Fast/;
use Data::Dump;

sub load {
    my ($self, $authinfo, $c) = @_;
    # Store supports finding by id,  username.
    if ( exists( $authinfo->{'id'} ) ) {
		my $u = $self->user_model->find($authinfo->{'id'});		
		$self->_user( $u );
    } elsif ( exists( $authinfo->{'username'} ) ) {	
		my $u;
		eval { $u = $self->user_model->find({ username => $authinfo->{'username'}}); };
		warn "u2: $u, $@ \n\n";
		eval { $self->_user( $u ); };        
		warn "db2: $@ \n\n\n";
    }
    if ($self->get_object) {
        return $self;
    } else {
        return undef;
    }
}
1;
__END__


4. Logging in user in controller:

if ( $c->authenticate({ username => $uname, password => $pword, }) ) {
	#
}


This is someone else's code I'm attempting to fix.
Can anyone spot why this is occurring and how I might be able to fix?

Regards,
Anthony



More information about the Catalyst mailing list