File Coverage

blib/lib/meon/Web/Form/PasswordReset.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package meon::Web::Form::PasswordReset;
2              
3 2     2   11530426 use meon::Web::Member;
  0            
  0            
4              
5             use HTML::FormHandler::Moose;
6             extends 'HTML::FormHandler';
7             with 'meon::Web::Role::Form';
8              
9             has '+name' => (default => 'form_password_reset');
10             has '+widget_wrapper' => ( default => 'Bootstrap' );
11              
12             has_field 'email' => ( type => 'Email', required => 1, label => 'Email' );
13             has_field 'submit' => ( type => 'Submit', value => 'Submit', );
14              
15             sub submitted {
16             my ($self) = @_;
17              
18             my $c = $self->c;
19             $c->log->debug(__PACKAGE__.' '.Data::Dumper::Dumper($c->req->params))
20             if $c->debug;
21              
22             my $members_folder = $c->default_auth_store->folder;
23             my $detach = $self->get_config_text('detach');
24             my $from = $self->get_config_text('from');
25             my $pw_change = $self->get_config_text('pw-change');
26              
27             my $email = $self->field('email')->value;
28             my $member = meon::Web::Member->find_by_email(
29             members_folder => $members_folder,
30             email => $email,
31             );
32              
33             unless ($member) {
34             $self->field('email')->add_error('no such email found');
35             return;
36             }
37              
38             $member->send_password_reset(
39             $from,
40             $c->uri_for($pw_change),
41             );
42             $self->detach($detach);
43             }
44              
45             no HTML::FormHandler::Moose;
46              
47             1;