made listview do paging and ordering and all sorts of stupid shit. nobody is welcome...
[catagits/Reaction.git] / lib / Reaction / InterfaceModel / Action / User / ChangePassword.pm
CommitLineData
7adfd53f 1package Reaction::InterfaceModel::Action::User::ChangePassword;
2
3use Reaction::Class;
4
5class ChangePassword is 'Reaction::InterfaceModel::Action::User::SetPassword', which {
6 has old_password => (isa => 'Password', is => 'rw', lazy_fail => 1);
7
8 around error_for_attribute => sub {
9 my $super = shift;
10 my ($self, $attr) = @_;
11 if ($attr->name eq 'old_password') {
12 return "Old password incorrect"
13 unless $self->verify_old_password;
14 }
15 #return $super->(@_); #commented out because the original didn't super()
16 };
17
18 around can_apply => sub {
19 my $super = shift;
20 my ($self) = @_;
21 return 0 unless $self->verify_old_password;
22 return $super->(@_);
23 };
24
25 implements verify_old_password => as {
26 my $self = shift;
27 return unless $self->has_old_password;
28
29 my $user = $self->target_model;
30 return $user->can("check_password") ?
31 $user->check_password($self->old_password) :
32 $self->old_password eq $user->password;
33 };
34
35};
36
371;
38
39=head1 NAME
40
41Reaction::InterfaceModel::Action::User::ChangePassword
42
43=head1 DESCRIPTION
44
45=head1 METHODS
46
47=head2 old_password
48
49=head2 verify_old_password
50
51=head1 SEE ALSO
52
53L<Reaction::InterfaceModel::Action::DBIC::User::ChangePassword>
54
55=head1 AUTHORS
56
57See L<Reaction::Class> for authors.
58
59=head1 LICENSE
60
61See L<Reaction::Class> for the license.
62
63=cut