aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/InterfaceModel
diff options
context:
space:
mode:
authorwreis <wreis@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-10-30 02:25:18 +0000
committerwreis <wreis@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-10-30 02:25:18 +0000
commitdc6a08d585bd4bdb3d04e7711f9ab7f895e2266a (patch)
tree27f16d339268d10d5860873cf1d3b7fe99b44b7e /lib/Reaction/InterfaceModel
parent2676d246adab0c8bb8643584a7e2042c5d973d6f (diff)
downloadreaction-dc6a08d585bd4bdb3d04e7711f9ab7f895e2266a.tar.gz
reaction-dc6a08d585bd4bdb3d04e7711f9ab7f895e2266a.zip
fixed verify_confirmation_code | added do_apply
Diffstat (limited to 'lib/Reaction/InterfaceModel')
-rw-r--r--lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm34
1 files changed, 22 insertions, 12 deletions
diff --git a/lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm b/lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm
index 3c5d8d6..a204c7b 100644
--- a/lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm
+++ b/lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm
@@ -1,22 +1,19 @@
package Reaction::InterfaceModel::Action::User::ResetPassword;
use Reaction::Class;
-use Digest::MD5;
-
-use aliased
- 'Reaction::InterfaceModel::Action::User::Role::ConfirmationCodeSupport';
use aliased 'Reaction::InterfaceModel::Action::User::SetPassword';
-
use Reaction::Types::Core qw(NonEmptySimpleStr);
-
use namespace::clean -except => [ qw(meta) ];
-extends SetPassword;
-with ConfirmationCodeSupport;
+extends SetPassword;
-has confirmation_code =>
+has confirmation_code =>
(isa => NonEmptySimpleStr, is => 'rw', lazy_fail => 1);
+has 'user' => (
+ is => 'rw', metaclass => 'Reaction::Meta::Attribute',
+);
+
around error_for_attribute => sub {
my $super = shift;
my ($self, $attr) = @_;
@@ -26,11 +23,24 @@ around error_for_attribute => sub {
}
#return $super->(@_); #commented out because the original didn't super()
};
+
sub verify_confirmation_code {
my $self = shift;
- return $self->has_confirmation_code
- && ($self->confirmation_code eq $self->generate_confirmation_code);
-};
+ my $supplied_code = $self->confirmation_code;
+ my $user = $self->target_model->find_by_confirmation_code($supplied_code)
+ if $self->has_confirmation_code;
+ if ( defined $user ) {
+ $self->user($user);
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub do_apply {
+ my $self = shift;
+ return $self->user->reset_password($self->new_password);
+}
__PACKAGE__->meta->make_immutable;