package Catalyst::Authentication::Store::Minimal;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
-
-use Catalyst::Authentication::User::Hash;
+with 'MooseX::Emulate::Class::Accessor::Fast';
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 {
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 {
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<Catalyst::Authentication::User::Hash> will be used. If you define your
+own class, it must inherit from L<Catalyst::Authentication::User::Hash>.
+
=item users
This is a simple hash of users, the keys are the usenames, and the values are