1 package Reaction::InterfaceModel::Action::User::ResetPassword;
4 use aliased 'Reaction::InterfaceModel::Action::User::SetPassword';
5 use Reaction::Types::Core qw(NonEmptySimpleStr);
6 use namespace::clean -except => [ qw(meta) ];
10 has confirmation_code =>
11 (isa => NonEmptySimpleStr, is => 'rw', lazy_fail => 1);
14 is => 'rw', metaclass => 'Reaction::Meta::Attribute',
15 predicate => 'has_user',
18 around can_apply => sub {
21 return 0 unless $self->verify_confirmation_code;
25 sub verify_confirmation_code {
27 my $supplied_code = $self->confirmation_code;
28 my $user = $self->target_model->find_by_confirmation_code($supplied_code)
29 if $self->has_confirmation_code;
30 if ( defined $user ) {
38 around error_for_attribute => sub {
40 my ($self, $attr) = @_;
41 if ($attr->name eq 'confirmation_code') {
42 return 'Confirmation code incorrect' unless $self->has_user;
49 return $self->user->reset_password($self->new_password);
52 __PACKAGE__->meta->make_immutable;
59 Reaction::InterfaceModel::Action::User::ResetPassword
63 =head2 error_for_attribute
65 =head2 confirmation_code
67 =head2 verify_confirmation_code
71 L<Reaction::InterfaceModel::Action::DBIC::User::ResetPassword>
73 L<Reaction::InterfaceModel::Action::User::Role::ConfirmationCodeSupport>
77 See L<Reaction::Class> for authors.
81 See L<Reaction::Class> for the license.