X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAuthentication%2FStore%2FMinimal.pm;h=63a0afd728722791393356410e96478b63281758;hb=4e953732d2cad72dd5822fb21034a06da10b2264;hp=7c03198ebf7ac6f593dfe22b480bcacce495f9e6;hpb=6805e6fe59336c0540e30319936cb2c7aeba0ccd;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/lib/Catalyst/Authentication/Store/Minimal.pm b/lib/Catalyst/Authentication/Store/Minimal.pm index 7c03198..63a0afd 100644 --- a/lib/Catalyst/Authentication/Store/Minimal.pm +++ b/lib/Catalyst/Authentication/Store/Minimal.pm @@ -3,18 +3,24 @@ package Catalyst::Authentication::Store::Minimal; use strict; use warnings; -use Catalyst::Authentication::User::Hash; use Scalar::Util qw( blessed ); use base qw/Class::Accessor::Fast/; BEGIN { - __PACKAGE__->mk_accessors(qw/userhash/); + __PACKAGE__->mk_accessors(qw/userhash userclass/); } sub new { my ( $class, $config, $app, $realm) = @_; - bless { userhash => $config->{'users'} }, $class; + my $self = bless { + userhash => $config->{'users'}, + userclass => $config->{'user_class'} || "Catalyst::Authentication::User::Hash", + }, $class; + + Catalyst::Utils::ensure_class_loaded( $self->userclass ); + + return $self; } sub from_session { @@ -41,7 +47,7 @@ sub find_user { if ( ref($user) eq "HASH") { $user->{id} ||= $id; - return bless $user, "Catalyst::Authentication::User::Hash"; + return bless $user, $self->userclass; } elsif ( ref($user) && blessed($user) && $user->isa('Catalyst::Authentication::User::Hash')) { return $user; } else { @@ -148,6 +154,12 @@ Catalyst::Authentication::Store::Minimal is loaded as the user store. For this module to be used, this must be set to 'Minimal'. +=item user_class + +The class used for the user object. If you don't specify a class name, the +default L will be used. If you define your +own class, it must inherit from L. + =item users This is a simple hash of users, the keys are the usenames, and the values are