made listview do paging and ordering and all sorts of stupid shit. nobody is welcome...
[catagits/Reaction.git] / lib / Reaction / InterfaceModel / Action / User / SetPassword.pm
1 package Reaction::InterfaceModel::Action::User::SetPassword;
2
3 use Reaction::Class;
4 use Reaction::InterfaceModel::Action;
5
6 class SetPassword is 'Reaction::InterfaceModel::Action', which {
7
8   has new_password => (isa => 'Password', is => 'rw', lazy_fail => 1);
9   has confirm_new_password => 
10       (isa => 'Password', is => 'rw', lazy_fail => 1);
11   
12   around error_for_attribute => sub {
13     my $super = shift;
14     my ($self, $attr) = @_;
15     if ($attr->name eq 'confirm_new_password') {
16       return "New password doesn't match"
17         unless $self->verify_confirm_new_password;
18     }
19     return $super->(@_);
20   };
21   
22   around can_apply => sub {
23     my $super = shift;
24     my ($self) = @_;
25     return 0 unless $self->verify_confirm_new_password;
26     return $super->(@_);
27   };
28   
29   implements verify_confirm_new_password => as {
30     my $self = shift;
31     return $self->has_new_password && $self->has_confirm_new_password
32         && ($self->new_password eq $self->confirm_new_password);
33   };
34
35 };
36
37 1;
38
39 =head1 NAME
40
41 Reaction::InterfaceModel::Action::User::SetPassword
42
43 =head1 DESCRIPTION
44
45 =head1 ATTRIBUTES
46
47 =head2 new_password
48
49 =head2 confirm_new_password
50
51 =head1 METHODS
52
53 =head2 verify_confirm_new_password
54
55 Tests to make sure that C<new_password> and C<confirm_new_password> match.
56
57 =head1 SEE ALSO
58
59 L<Reaction::InterfaceModel::Action::DBIC::User::SetPassword>
60
61 =head1 AUTHORS
62
63 See L<Reaction::Class> for authors.
64
65 =head1 LICENSE
66
67 See L<Reaction::Class> for the license.
68
69 =cut