X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FAuthentication.pm;h=d5173aebd2a7ed6221f6eab8b5bf3eb34457dba7;hb=1bd3c97fb462937338ca32079aa522e8776c8994;hp=8f788486462fbf380c389b47db10758c0e611e1f;hpb=5435c34839d8aaa4a991612d7018a6eef6bc197d;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/lib/Catalyst/Plugin/Authentication.pm b/lib/Catalyst/Plugin/Authentication.pm index 8f78848..d5173ae 100644 --- a/lib/Catalyst/Plugin/Authentication.pm +++ b/lib/Catalyst/Plugin/Authentication.pm @@ -2,17 +2,17 @@ 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 ) = @_; @@ -32,7 +32,12 @@ sub logout { 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 { @@ -52,7 +57,7 @@ sub prepare { 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} ) { @@ -72,6 +77,8 @@ sub setup { use_session => 1, %$cfg, ); + + $c->NEXT::setup(@_); } __PACKAGE__;