fix Module::Install without . in @INC
[catagits/Catalyst-Plugin-Authentication.git] / lib / Catalyst / Plugin / Authentication / Store / Minimal.pm
CommitLineData
06675d2e 1package Catalyst::Plugin::Authentication::Store::Minimal;
06675d2e 2
3use strict;
4use warnings;
90240305 5use MRO::Compat;
06675d2e 6
290e5a7e 7use Catalyst::Authentication::Store::Minimal ();
8
9## backwards compatibility
10sub setup {
11 my $c = shift;
12
13 ### If a user does 'use Catalyst qw/Authentication::Store::Minimal/'
14 ### he will be proxied on to this setup routine (and only then --
15 ### non plugins should NOT have their setup routine invoked!)
16 ### Beware what we pass to the 'new' routine; it wants
17 ### a config has with a top level key 'users'. New style
18 ### configs do not have this, and split by realms. If we
19 ### blindly pass this to new, we will 1) overwrite what we
20 ### already passed and 2) make ->userhash undefined, which
21 ### leads to:
22 ### Can't use an undefined value as a HASH reference at
23 ### lib/Catalyst/Authentication/Store/Minimal.pm line 38.
24 ###
25 ### So only do this compatibility call if:
90240305 26 ### 1) we have a {users} config directive
290e5a7e 27 ###
28 ### Ideally we could also check for:
29 ### 2) we don't already have a ->userhash
90240305 30 ### however, that's an attribute of an object we can't
290e5a7e 31 ### access =/ --kane
90240305 32
290e5a7e 33 my $cfg = $c->config->{'Plugin::Authentication'}->{users}
34 ? $c->config->{'Plugin::Authentication'}
35 : undef;
36
37 $c->default_auth_store( Catalyst::Authentication::Store::Minimal->new( $cfg, $c ) ) if $cfg;
90240305 38
675fe850 39 $c->next::method(@_);
290e5a7e 40}
41
42foreach my $method (qw/ get_user user_supports find_user from_session /) {
43 no strict 'refs';
44 *{$method} = sub { __PACKAGE__->default_auth_store->$method( @_ ) };
45}
06675d2e 46
47__PACKAGE__;
48
49__END__
50
51=pod
52
53=head1 NAME
54
5c5af345 55Catalyst::Plugin::Authentication::Store::Minimal - Compatibility shim
06675d2e 56
06675d2e 57=head1 DESCRIPTION
58
5c5af345 59THIS IS A COMPATIBILITY SHIM. It allows old configurations of Catalyst
60Authentication to work without code changes.
06675d2e 61
e1e68578 62B<DO NOT USE IT IN ANY NEW CODE!>
63
5c5af345 64Please see L<Catalyst::Authentication::Store::Minimal> for more information.
06675d2e 65
95114c34 66=head1 METHODS
67
68=over
69
70=item find_user
71
72=item from_session
73
74=item get_user
75
76=item setup
77
78=item user_supports
79
80=back
81
82=cut