lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm

filter: Statementstmt 48.7% 20 / 41 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 50.0% 1 / 2 totaltotal 40.3% 25 / 62 CC 6 SCAR 18.8
CC
6
Cov
39%
verify_confirmation_code
12.0
__ANON__
12.0
__ANON__
6.0
CRAP 6.6
« lib/Reaction/Role/Meta/Attribute.pm ↑ Summary lib/Reaction/InterfaceModel/Collection.pm »
1 package Reaction::InterfaceModel::Action::User::ResetPassword;
2  
3 1 ▶use Reaction::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use aliased 'Reaction::InterfaceModel::Action::User::SetPassword';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Reaction::Types::Core qw(NonEmptySimpleStr);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use namespace::clean -except => [ qw(meta) ];
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 extends SetPassword;
9  
10 1 has confirmation_code =>
11 (isa => NonEmptySimpleStr, is => 'rw', lazy_fail => 1);
12  
13 1 has 'user' => (
14 is => 'rw', metaclass => 'Reaction::Meta::Attribute',
15 predicate => 'has_user',
16 );
17  
18 # verification needs to be done here, since there are cases where
19 # can_apply doesn't run, such as fields being left blank, invalid, etc.
20 0 ▶around sync_all => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 0 my $super = shift;
22 0 my ($self) = @_;
23 0 $self->verify_confirmation_code;
24 0 $self->$super(@_);
25 1 };
26  
27 0 ▶around can_apply => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
28 0 my $super = shift;
29 0 my ($self) = @_;
30 0 ▶ return 0 unless $self->has_user;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_user 0 0 0
31 0 return $super->(@_);
32 1 };
33  
34 0 ▶sub verify_confirmation_code {
Subroutine verify_confirmation_code: not called CC=3 SCAR=24.8
Pod documented
35 0 my $self = shift;
36 0 ▶ return unless $self->has_confirmation_code;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_confirmation_code 0 0 0
37 0 my $model = $self->target_model;
38 0 my $supplied_code = $self->confirmation_code;
39 0 ▶ if (defined(my $user = $model->find_by_confirmation_code($supplied_code))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $user = $model->find_by_confirmation_code($supplied_code))) 0 0 0
40 0 $self->user($user);
41 }
42 }
43  
44 0 ▶around error_for_attribute => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
45 0 my $super = shift;
46 0 my ($self, $attr) = @_;
47 0 ▶ if ($attr->name eq 'confirmation_code') {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr->name eq "confirmation_code") 0 0 0
48 0 ▶ return 'Confirmation code incorrect' unless $self->has_user;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_user 0 0 0
49 }
50 0 return $super->(@_);
51 1 };
52  
53 0 ▶sub do_apply {
Subroutine do_apply: not called CC=1 SCAR=6.9
Pod undocumented
54 0 my $self = shift;
55 0 return $self->user->reset_password($self->new_password);
56 }
57  
58 1 __PACKAGE__->meta->make_immutable;
59  
60  
61 1 1;
62  
63 =head1 NAME
64  
65 Reaction::InterfaceModel::Action::User::ResetPassword
66  
67 =head1 DESCRIPTION
68  
69 =head2 error_for_attribute
70  
71 =head2 confirmation_code
72  
73 =head2 verify_confirmation_code
74  
75 =head1 SEE ALSO
76  
77 L<Reaction::InterfaceModel::Action::DBIC::User::ResetPassword>
78  
79 L<Reaction::InterfaceModel::Action::User::Role::ConfirmationCodeSupport>
80  
81 =head1 AUTHORS
82  
83 See L<Reaction::Class> for authors.
84  
85 =head1 LICENSE
86  
87 See L<Reaction::Class> for the license.
88  
89 =cut
« lib/Reaction/Role/Meta/Attribute.pm ↑ Summary lib/Reaction/InterfaceModel/Collection.pm »