Commit | Line | Data |
06675d2e |
1 | package Catalyst::Plugin::Authentication::Store::Minimal; |
06675d2e |
2 | |
3 | use strict; |
4 | use warnings; |
90240305 |
5 | use MRO::Compat; |
06675d2e |
6 | |
290e5a7e |
7 | use Catalyst::Authentication::Store::Minimal (); |
8 | |
9 | ## backwards compatibility |
10 | sub 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 | |
42 | foreach 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 |
55 | Catalyst::Plugin::Authentication::Store::Minimal - Compatibility shim |
06675d2e |
56 | |
06675d2e |
57 | =head1 DESCRIPTION |
58 | |
5c5af345 |
59 | THIS IS A COMPATIBILITY SHIM. It allows old configurations of Catalyst |
60 | Authentication to work without code changes. |
06675d2e |
61 | |
e1e68578 |
62 | B<DO NOT USE IT IN ANY NEW CODE!> |
63 | |
5c5af345 |
64 | Please 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 |