Fix bug, patch from Anthony Gladdish on mailing list
[catagits/Catalyst-Authentication-Store-DBIx-Class.git] / t / lib / Catalyst / Authentication / Store / Person / User.pm
diff --git a/t/lib/Catalyst/Authentication/Store/Person/User.pm b/t/lib/Catalyst/Authentication/Store/Person/User.pm
new file mode 100644 (file)
index 0000000..b7b8828
--- /dev/null
@@ -0,0 +1,25 @@
+package Catalyst::Authentication::Store::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) = @_;    
+       if ( exists( $authinfo->{'id'} ) ) {            
+        $self->_user( $c->model('TestApp::User')->find($authinfo->{'id'}) );           
+    } elsif ( exists( $authinfo->{'username'} ) ) {
+               my $u = $c->model('TestApp::User')->find({ username => $authinfo->{'username'} });
+           $self->_user( $u );
+       }
+    if ($self->get_object) {
+        return $self;
+    } else {
+        return undef;
+    }
+}
+
+1;
+__END__
\ No newline at end of file