3ef645d1d7ce29d0e193b691ebf27b102d854d44
[catagits/Reaction.git] / lib / Reaction / InterfaceModel / Action / User / ResetPassword.pm
1 package Reaction::InterfaceModel::Action::User::ResetPassword;
2
3 use Reaction::Class;
4 use Digest::MD5;
5
6 use aliased
7   'Reaction::InterfaceModel::Action::User::Role::ConfirmationCodeSupport';
8 use aliased 'Reaction::InterfaceModel::Action::User::SetPassword';
9
10 class ResetPassword is SetPassword, which {
11
12   does ConfirmationCodeSupport;
13
14   has confirmation_code => 
15       (isa => 'NonEmptySimpleStr', is => 'rw', lazy_fail => 1);
16   
17   around error_for_attribute => sub {
18     my $super = shift;
19     my ($self, $attr) = @_;
20     if ($attr->name eq 'confirmation_code') {
21       return "Confirmation code incorrect"
22         unless $self->verify_confirmation_code;
23     }
24     #return $super->(@_); #commented out because the original didn't super()
25   };
26   
27   implements verify_confirmation_code => as {
28     my $self = shift;
29     return $self->has_confirmation_code
30         && ($self->confirmation_code eq $self->generate_confirmation_code);
31   };
32
33 };
34
35 1;
36
37 =head1 NAME
38
39 Reaction::InterfaceModel::Action::User::ResetPassword
40
41 =head1 DESCRIPTION
42
43 =head2 error_for_attribute
44
45 =head2 confirmation_code
46
47 =head2 verify_confirmation_code
48
49 =head1 SEE ALSO
50
51 L<Reaction::InterfaceModel::Action::DBIC::User::ResetPassword>
52
53 L<Reaction::InterfaceModel::Action::User::Role::ConfirmationCodeSupport>
54
55 =head1 AUTHORS
56
57 See L<Reaction::Class> for authors.
58
59 =head1 LICENSE
60
61 See L<Reaction::Class> for the license.
62
63 =cut