From: Yuval Kogman Date: Wed, 9 Nov 2005 00:09:17 +0000 (+0000) Subject: ACL + tests X-Git-Tag: v0.01~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0c4ddd064218a77c17d1bd59fa2963ee31f594b4;p=catagits%2FCatalyst-Plugin-Authentication.git ACL + tests misc fixes for the authen, authz::roles move dummy session store out of t/lib so that it's reusable --- diff --git a/lib/Catalyst/Plugin/Authentication/Credential/Password.pm b/lib/Catalyst/Plugin/Authentication/Credential/Password.pm index 0b05e18..3e3db2d 100644 --- a/lib/Catalyst/Plugin/Authentication/Credential/Password.pm +++ b/lib/Catalyst/Plugin/Authentication/Credential/Password.pm @@ -24,7 +24,7 @@ sub login { || 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"); diff --git a/lib/Catalyst/Plugin/Authentication/Store/Minimal/Backend.pm b/lib/Catalyst/Plugin/Authentication/Store/Minimal/Backend.pm index 5eecd3d..7bb0a1c 100644 --- a/lib/Catalyst/Plugin/Authentication/Store/Minimal/Backend.pm +++ b/lib/Catalyst/Plugin/Authentication/Store/Minimal/Backend.pm @@ -17,10 +17,27 @@ sub new { 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; } diff --git a/lib/Catalyst/Plugin/Authentication/User/Hash.pm b/lib/Catalyst/Plugin/Authentication/User/Hash.pm index 72a57e8..f7cbe5a 100644 --- a/lib/Catalyst/Plugin/Authentication/User/Hash.pm +++ b/lib/Catalyst/Plugin/Authentication/User/Hash.pm @@ -9,7 +9,7 @@ use warnings; sub new { my $class = shift; - bless {@_}, $class; + bless { @_ }, $class; } sub AUTOLOAD { @@ -22,7 +22,9 @@ sub AUTOLOAD { } my $data = $self->{$key}; - $self->{__hash_obj_key_is_array}{$key} ? @$data : $data; + ( $self->{__hash_obj_key_is_array}{$key} || $key =~ /roles/ ) + ? @$data + : $data; } my %features = ( diff --git a/t/live_app_session.t b/t/live_app_session.t index cb97025..3ebc3d0 100644 --- a/t/live_app_session.t +++ b/t/live_app_session.t @@ -7,11 +7,8 @@ use Test::More; 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; } {