X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAuthentication%2FStore%2FMinimal.pm;h=6fa764fb5b669366cdd559e28617013df22cb122;hb=b7a9f78dff3c8833cfd442776bf416999fc2e4fd;hp=155a921c9f07db0e5cc06081a6cfeb5a72eda9e5;hpb=bc119a79520c1f16ddb846e22cfb0b63e15ab65d;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/lib/Catalyst/Authentication/Store/Minimal.pm b/lib/Catalyst/Authentication/Store/Minimal.pm index 155a921..6fa764f 100644 --- a/lib/Catalyst/Authentication/Store/Minimal.pm +++ b/lib/Catalyst/Authentication/Store/Minimal.pm @@ -77,12 +77,32 @@ sub get_user { sub setup { my $c = shift; - $c->default_auth_store( - __PACKAGE__->new( - $c->config->{'Plugin::Authentication'}, $c - ) - ); + ### 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( __PACKAGE__->new( $cfg, $c ) ) if $cfg; + $c->NEXT::setup(@_); }