X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FAuthentication%2FStore%2FMinimal.pm;h=f79b97e6ebd48562821d2a41a05632a57998a217;hb=675fe850ff8ef284e35f9b78141543187df59d72;hp=bc4a32e8b37238b4e9f6dc2fdcea8d5f8b6e9dd8;hpb=e1e685783fb9bf6c25835516479d27b9d60843aa;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/lib/Catalyst/Plugin/Authentication/Store/Minimal.pm b/lib/Catalyst/Plugin/Authentication/Store/Minimal.pm index bc4a32e..f79b97e 100644 --- a/lib/Catalyst/Plugin/Authentication/Store/Minimal.pm +++ b/lib/Catalyst/Plugin/Authentication/Store/Minimal.pm @@ -2,8 +2,47 @@ package Catalyst::Plugin::Authentication::Store::Minimal; use strict; use warnings; +use MRO::Compat; -use base qw/Catalyst::Authentication::Store::Minimal/; +use Catalyst::Authentication::Store::Minimal (); + +## backwards compatibility +sub setup { + my $c = shift; + + ### If a user does 'use Catalyst qw/Authentication::Store::Minimal/' + ### he will be proxied on to this setup routine (and only then -- + ### non plugins should NOT have their setup routine invoked!) + ### Beware what we pass to the 'new' routine; it wants + ### a config has with a top level key 'users'. New style + ### configs do not have this, and split by realms. If we + ### blindly pass this to new, we will 1) overwrite what we + ### already passed and 2) make ->userhash undefined, which + ### leads to: + ### Can't use an undefined value as a HASH reference at + ### lib/Catalyst/Authentication/Store/Minimal.pm line 38. + ### + ### So only do this compatibility call if: + ### 1) we have a {users} config directive + ### + ### Ideally we could also check for: + ### 2) we don't already have a ->userhash + ### however, that's an attribute of an object we can't + ### access =/ --kane + + my $cfg = $c->config->{'Plugin::Authentication'}->{users} + ? $c->config->{'Plugin::Authentication'} + : undef; + + $c->default_auth_store( Catalyst::Authentication::Store::Minimal->new( $cfg, $c ) ) if $cfg; + + $c->next::method(@_); +} + +foreach my $method (qw/ get_user user_supports find_user from_session /) { + no strict 'refs'; + *{$method} = sub { __PACKAGE__->default_auth_store->$method( @_ ) }; +} __PACKAGE__; @@ -24,3 +63,20 @@ B Please see L for more information. +=head1 METHODS + +=over + +=item find_user + +=item from_session + +=item get_user + +=item setup + +=item user_supports + +=back + +=cut