aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm
blob: 2637dc08cd3e04059cee5b0f36505dd4c5e25cba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package Reaction::InterfaceModel::Action::User::ResetPassword;

use Reaction::Class;
use Digest::MD5;

use aliased
  'Reaction::InterfaceModel::Action::User::Role::ConfirmationCodeSupport';
use aliased 'Reaction::InterfaceModel::Action::User::SetPassword';

use Reaction::Types::Core qw(NonEmptySimpleStr);

class ResetPassword is SetPassword, which {

  does ConfirmationCodeSupport;

  has confirmation_code => 
      (isa => NonEmptySimpleStr, is => 'rw', lazy_fail => 1);
  
  around error_for_attribute => sub {
    my $super = shift;
    my ($self, $attr) = @_;
    if ($attr->name eq 'confirmation_code') {
      return "Confirmation code incorrect"
        unless $self->verify_confirmation_code;
    }
    #return $super->(@_); #commented out because the original didn't super()
  };
  
  implements verify_confirmation_code => as {
    my $self = shift;
    return $self->has_confirmation_code
        && ($self->confirmation_code eq $self->generate_confirmation_code);
  };

};

1;

=head1 NAME

Reaction::InterfaceModel::Action::User::ResetPassword

=head1 DESCRIPTION

=head2 error_for_attribute

=head2 confirmation_code

=head2 verify_confirmation_code

=head1 SEE ALSO

L<Reaction::InterfaceModel::Action::DBIC::User::ResetPassword>

L<Reaction::InterfaceModel::Action::User::Role::ConfirmationCodeSupport>

=head1 AUTHORS

See L<Reaction::Class> for authors.

=head1 LICENSE

See L<Reaction::Class> for the license.

=cut