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 return unless $self->has_confirmation_code;
28 my $model = $self->target_model;
29 my $supplied_code = $self->confirmation_code;
30 if (defined(my $user = $model->find_by_confirmation_code($supplied_code))) {
37 around error_for_attribute => sub {
39 my ($self, $attr) = @_;
40 if ($attr->name eq 'confirmation_code') {
41 return 'Confirmation code incorrect' unless $self->has_user;
48 return $self->user->reset_password($self->new_password);
51 __PACKAGE__->meta->make_immutable;
58 Reaction::InterfaceModel::Action::User::ResetPassword
62 =head2 error_for_attribute
64 =head2 confirmation_code
66 =head2 verify_confirmation_code
70 L<Reaction::InterfaceModel::Action::DBIC::User::ResetPassword>
72 L<Reaction::InterfaceModel::Action::User::Role::ConfirmationCodeSupport>
76 See L<Reaction::Class> for authors.
80 See L<Reaction::Class> for the license.