File Coverage

blib/lib/WWW/Picnic/Result/Login.pm
Criterion Covered Total %
statement 7 7 100.0
branch 2 4 50.0
condition 1 3 33.3
subroutine 3 3 100.0
pod 2 2 100.0
total 15 19 78.9


line stmt bran cond sub pod time code
1             package WWW::Picnic::Result::Login;
2             our $VERSION = '0.100';
3             our $AUTHORITY = 'cpan:GETTY';
4             # ABSTRACT: Picnic login result with 2FA status
5              
6 2     2   15 use Moo;
  2         6  
  2         15  
7              
8             extends 'WWW::Picnic::Result';
9              
10              
11             has auth_key => (
12             is => 'ro',
13             lazy => 1,
14             default => sub { shift->_get('auth_key') },
15             );
16              
17              
18             has user_id => (
19             is => 'ro',
20             lazy => 1,
21             default => sub { shift->_get('user_id') },
22             );
23              
24              
25             has second_factor_authentication_required => (
26             is => 'ro',
27             lazy => 1,
28             default => sub { shift->_get('second_factor_authentication_required') || 0 },
29             );
30              
31              
32             has show_second_factor_authentication_intro => (
33             is => 'ro',
34             lazy => 1,
35             default => sub { shift->_get('show_second_factor_authentication_intro') || 0 },
36             );
37              
38              
39             sub requires_2fa {
40 2     2 1 6 my ( $self ) = @_;
41 2 50       64 return $self->second_factor_authentication_required ? 1 : 0;
42             }
43              
44              
45             sub is_authenticated {
46 1     1 1 4 my ( $self ) = @_;
47 1 50 33     37 return $self->auth_key && !$self->requires_2fa ? 1 : 0;
48             }
49              
50              
51             1;
52              
53             __END__