File Coverage

blib/lib/Catalyst/Plugin/Authentication/Store/Minimal.pm
Criterion Covered Total %
statement 19 20 95.0
branch 4 4 100.0
condition n/a
subroutine 6 7 85.7
pod 1 1 100.0
total 30 32 93.7


line stmt bran cond sub pod time code
1             package Catalyst::Plugin::Authentication::Store::Minimal;
2              
3 4     4   6144854 use strict;
  4         11  
  4         214  
4 4     4   32 use warnings;
  4         10  
  4         337  
5 4     4   46 use MRO::Compat;
  4         17  
  4         102  
6              
7 4     4   2187 use Catalyst::Authentication::Store::Minimal ();
  4         57  
  4         783  
8              
9             ## backwards compatibility
10             sub setup {
11 4     4 1 297 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:
26             ### 1) we have a {users} config directive
27             ###
28             ### Ideally we could also check for:
29             ### 2) we don't already have a ->userhash
30             ### however, that's an attribute of an object we can't
31             ### access =/ --kane
32              
33             my $cfg = $c->config->{'Plugin::Authentication'}->{users}
34 4 100       34 ? $c->config->{'Plugin::Authentication'}
35             : undef;
36              
37 4 100       553 $c->default_auth_store( Catalyst::Authentication::Store::Minimal->new( $cfg, $c ) ) if $cfg;
38              
39 4         242 $c->next::method(@_);
40             }
41              
42             foreach my $method (qw/ get_user user_supports find_user from_session /) {
43 4     4   46 no strict 'refs';
  4         9  
  4         478  
44 0     0     *{$method} = sub { __PACKAGE__->default_auth_store->$method( @_ ) };
45             }
46              
47             __PACKAGE__;
48              
49             __END__
50              
51             =pod
52              
53             =head1 NAME
54              
55             Catalyst::Plugin::Authentication::Store::Minimal - Compatibility shim
56              
57             =head1 DESCRIPTION
58              
59             THIS IS A COMPATIBILITY SHIM. It allows old configurations of Catalyst
60             Authentication to work without code changes.
61              
62             B<DO NOT USE IT IN ANY NEW CODE!>
63              
64             Please see L<Catalyst::Authentication::Store::Minimal> for more information.
65              
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