Jifty/Plugin/Authentication/Password/Action/ResendConfirmation.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 47 CC 4 SCAR 22.2
CC
4
Cov
0%
validate_email
20.0
arguments
2.0
setup
2.0
CRAP 9.2
1 use warnings;
2 use strict;
3  
4 =head1 NAME
5  
6 Jifty::Plugin::Authentication::Password::Action::ResendConfirmation - resend confirmation for new mail or password
7  
8 =cut
9  
10 package Jifty::Plugin::Authentication::Password::Action::ResendConfirmation;
11 use base qw/Jifty::Action/;
12  
13 __PACKAGE__->mk_accessors(qw(user_object));
14  
15  
16 =head2 arguments
17  
18 The field for C<ResendConfirmation> is:
19  
20 =over 4
21  
22 =item email: the email email
23  
24 =back
25  
26 =cut
27  
28 sub arguments {
29 return (
30 {
31 email => {
32 label => 'Email address',
33 mandatory => 1,
34 default_value => "",
35 },
36 }
37 );
38  
39 }
40  
41 =head2 setup
42  
43 Create an empty user object to work with
44  
45 =cut
46  
47 sub setup {
48 my $self = shift;
49
50 # Make a blank user object
51 $self->user_object(Jifty->app_class('Model','User')->new(current_user => Jifty->app_class('CurrentUser')->superuser));
52 }
53  
54 =head2 validate_email
55  
56 Make sure their email email is an unconfirmed user.
57  
58 =cut
59  
60 sub validate_email {
61 my $self = shift;
62 my $email = shift;
63  
64 unless ( $email =~ /\S\@\S/ ) {
65 return $self->validation_error(email => "Are you sure that's an email email?" );
66 }
67  
68 $self->user_object(Jifty->app_class('Model','User')->new(current_user => Jifty->app_class('CurrentUser')->superuser));
69 $self->user_object->load_by_cols( email => $email );
70 unless ($self->user_object->id) {
71 return $self->validation_error(email => "It doesn't look like there's an account by that name.");
72 }
73  
74 if ($self->user_object->email_confirmed) {
75 return $self->validation_error(email => "It looks like you're already confirmed.");
76  
77 }
78  
79 return $self->validation_ok('email');
80 }
81  
82 =head2 take_action
83  
84 Create a new unconfirmed user and send out a confirmation email.
85  
86 =cut
87  
88 sub take_action {
89 my $self = shift;
90 my $user = $self->user_object();
91  
92 Jifty->app_class('Notification','ConfirmEmail')->new( to => $user )->send;
93
94 $self->result->message("We've re-sent your confirmation.");
95  
96 return 1;
97 }
98  
99 1;