Fix calling User->can() as a class method. RT#90715
[catagits/Catalyst-Authentication-Store-DBIx-Class.git] / lib / Catalyst / Authentication / Store / DBIx / Class / User.pm
index 405ae75..18282a4 100644 (file)
@@ -261,7 +261,9 @@ sub can {
     my $self = shift;
     return $self->SUPER::can(@_) || do {
         my ($method) = @_;
-        if (not $self->_user) {
+        if (not ref $self) {
+            undef;
+        } elsif (not $self->_user) {
             undef;
         } elsif (my $code = $self->_user->can($method)) {
             sub { shift->_user->$code(@_) }
@@ -279,6 +281,8 @@ sub AUTOLOAD {
     (my $method) = (our $AUTOLOAD =~ /([^:]+)$/);
     return if $method eq "DESTROY";
 
+    return unless ref $self;
+
     if (my $code = $self->_user->can($method)) {
         return $self->_user->$code(@_);
     }