1 package Reaction::InterfaceModel::Action::User::ChangePassword;
5 use Reaction::Types::Core qw(Password);
7 use namespace::clean -except => [ qw(meta) ];
8 extends 'Reaction::InterfaceModel::Action::User::SetPassword';
11 has old_password => (isa => Password, is => 'rw', lazy_fail => 1);
13 around error_for_attribute => sub {
15 my ($self, $attr) = @_;
16 if ($attr->name eq 'old_password') {
17 return "Old password incorrect"
18 unless $self->verify_old_password;
20 #return $super->(@_); #commented out because the original didn't super()
23 around can_apply => sub {
26 return 0 unless $self->verify_old_password;
29 sub verify_old_password {
31 return unless $self->has_old_password;
33 my $user = $self->target_model;
34 return $user->can("check_password") ?
35 $user->check_password($self->old_password) :
36 $self->old_password eq $user->password;
39 __PACKAGE__->meta->make_immutable;
46 Reaction::InterfaceModel::Action::User::ChangePassword
54 =head2 verify_old_password
58 L<Reaction::InterfaceModel::Action::DBIC::User::ChangePassword>
62 See L<Reaction::Class> for authors.
66 See L<Reaction::Class> for the license.