Revision history for Perl extension Catalyst::Plugin::Authentication
+ - Allow user_class to be configured for Catalyst::Authentication::Store::Minimal
+ (Jochen Lutz <jlu@akk.org>)
+
0.10019 14 April 2012
- Upgrade code to use Moose compatibility layer (jnap)
- Added some rules to .gitignore for people using macs (jnap)
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 {
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