Store/FromSub.pm

filter: Statementstmt 21.6% 8 / 37 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 28.5% 2 / 7 Podpod 0.0% 0 / 5 totaltotal 15.6% 10 / 64 CC 8 SCAR 24.2
CC
8
Cov
16%
from_session
20.0
new
12.0
find_user
12.0
CRAP 11.3
↑ Summary FromSub/User/Object.pm »
1 package Catalyst::Authentication::Store::FromSub;
2 1 our $VERSION = '0.01';
3  
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # ABSTRACT: A storage class for Catalyst Authentication using one Catalyst Model class
8  
9 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
10 0 my ( $class, $config, $app ) = @_;
11  
12 # load User or Object module
13 0 my $user_type = $config->{user_type};
14 0 ▶ if ( $user_type eq 'Hash' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($user_type eq 'Hash') { } 0 0 0
elsif ($user_type eq 'Object') { } 0 0 0
15 0 Catalyst::Utils::ensure_class_loaded(
16 'Catalyst::Authentication::User::Hash');
17 0 $config->{user_type} = 'Catalyst::Authentication::User::Hash';
18 }
19 elsif ( $user_type eq 'Object' ) {
20 0 Catalyst::Utils::ensure_class_loaded(
21 'Catalyst::Authentication::FromSub::User::Object');
22 $config->{user_type} =
23 0 'Catalyst::Authentication::FromSub::User::Object';
24 }
25 else {
26 0 Catalyst::Utils::ensure_class_loaded($user_type);
27 }
28  
29 0 bless { config => $config }, $class;
30 }
31  
32 0 ▶sub from_session {
Subroutine from_session: not called CC=4 SCAR=30.0
Pod undocumented
33 0 my ( $self, $c, $id ) = @_;
34  
35 # Don't use data in session because data maybe changed in model_class sub auth.
36 # return $id if ref $id;
37  
38 0 ▶ my $id_field = $self->{config}->{id_field} || 'id';
Condition0%0/2
$self->{'config'}{'id_field'} || 'id'
l!l
00
MC/DC0%0/1
$self->{'config'}{'id_field'} || 'id'
$self->{'config'}{'id_field'}
Truth table0%0/2
A
A= $self->{'config'}{'id_field'}
Aresult
11
00
39 0 ▶ if ( ref $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $id) 0 0 0
40 0 ▶ if ( exists $id->{$id_field} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $id->{$id_field}) { } 0 0 0
41 0 return $self->find_user( { $id_field => $id->{$id_field} }, $c );
42 }
43 else {
44 0 return $id;
45 }
46 }
47  
48 0 $self->find_user( { $id_field => $id }, $c );
49 }
50  
51 0 ▶sub for_session {
Subroutine for_session: not called CC=1 SCAR=6.9
Pod undocumented
52 0 my ( $self, $c, $user ) = @_;
53  
54 0 return $user->for_session($c);
55 }
56  
57 0 ▶sub find_user {
Subroutine find_user: not called CC=3 SCAR=24.8
Pod undocumented
58 0 my ( $self, $userinfo, $c ) = @_;
59  
60 0 my $config = $self->{config};
61 0 my $model_class = $config->{model_class};
62 0 my $model = $c->model($model_class);
63  
64 0 my $user = $model->auth( $c, $userinfo );
65 0 ▶ return unless $user;
Branch: 1 branch
BranchTrueFalseTotal
unless $user 0 0 0
66  
67 0 ▶ if ( $config->{user_type} eq 'Catalyst::Authentication::User::Hash' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{'user_type'} eq 'Catalyst::Authentication::User::Hash') { } 0 0 0
68 0 return $config->{user_type}->new($user);
69 }
70 else {
71 return $config->{user_type}
72 0 ->new( { user => $user, storage => $self }, $c );
73 }
74 }
75  
76 0 ▶sub user_supports {
Subroutine user_supports: not called CC=1 SCAR=6.9
Pod undocumented
77 0 my $self = shift;
78  
79 # this can work as a class method on the user class
80 0 $self->{config}->{user_type}->supports(@_);
81 }
82  
83 1 1;
84 __END__
↑ Summary FromSub/User/Object.pm »