|| Catalyst::Exception->throw("Can't determine password for login");
}
- $user = $c->get_user($user)
+ $user = $c->get_user($user) || return
unless Scalar::Util::blessed($user)
and $user->isa("Catalyst:::Plugin::Authentication::User");
sub get_user {
my ( $self, $id ) = @_;
- my $user = $self->{hash}{$id};
-
- bless $user, "Catalyst::Plugin::Authentication::User::Hash"
- unless Scalar::Util::blessed($user);
+ return unless exists $self->{hash}{$id};
+
+ my $user = $self->{hash}{$id};
+
+ if ( ref $user ) {
+ if ( Scalar::Util::blessed($user) ) {
+ return $user;
+ }
+ elsif ( ref $user eq "HASH" ) {
+ return bless $user, "Catalyst::Plugin::Authentication::User::Hash";
+ }
+ else {
+ Catalyst::Exception->throw( "The user '$id' is a reference of type "
+ . ref($user)
+ . " but should be a HASH" );
+ }
+ }
+ else {
+ Catalyst::Exception->throw(
+ "The user '$id' is has to be a hash reference or an object");
+ }
return $user;
}
BEGIN {
eval { require Catalyst::Plugin::Session; require Catalyst::Plugin::Session::State::Cookie };
- if ($@) {
- plan skip_all => "This test needs Catalyst::Plugin::Session and Catalyst::Plugin::Session::State::Cookie installed";
- } else {
- plan tests => 12;
- }
+ plan skip_all => "This test needs Catalyst::Plugin::Session and Catalyst::Plugin::Session::State::Cookie installed" if $@;
+ plan tests => 12;
}
{