package Catalyst::Plugin::Authentication;
-use base qw/Class::Accessor::Fast/;
+use base qw/Class::Accessor::Fast Class::Data::Inheritable/;
-BEGIN { __PACKAGE__->mk_accessors(qw/user/) }
+BEGIN {
+ __PACKAGE__->mk_accessors(qw/user/);
+ __PACKAGE__->mk_classdata(qw/default_auth_store/);
+}
use strict;
use warnings;
-sub default_auth_store {
- my $c = shift;
- $c->config->{authentication}{store};
-}
+our $VERSION = "0.01";
sub set_authenticated {
my ( $c, $user ) = @_;
my $c = shift;
$c->user(undef);
- delete @{ $c->session }{qw/__user __user_class/};
+
+ if ( $c->isa("Catalyst::Plugin::Session")
+ and $c->config->{authentication}{use_session} )
+ {
+ delete @{ $c->session }{qw/__user __user_class/};
+ }
}
sub get_user {
my $c = shift->NEXT::prepare(@_);
if ( $c->isa("Catalyst::Plugin::Session")
- and $c->config->{authentication}{use_session}
+ and $c->default_auth_store
and !$c->user )
{
if ( $c->sessionid and my $user = $c->session->{__user} ) {
use_session => 1,
%$cfg,
);
+
+ $c->NEXT::setup(@_);
}
__PACKAGE__;