| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 48 | 0 | ▶ | return 'Confirmation code incorrect' unless $self->has_user; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ||||||||||