diff options
author | wreis <wreis@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2008-10-30 21:26:33 +0000 |
---|---|---|
committer | wreis <wreis@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2008-10-30 21:26:33 +0000 |
commit | d7faa27a5135c0d12c63ec0947a21de46e190ccd (patch) | |
tree | 841a5e961b4dcd0a91a342d85f3a39406ecf4fd8 /lib/Reaction/InterfaceModel | |
parent | dc6a08d585bd4bdb3d04e7711f9ab7f895e2266a (diff) | |
download | reaction-d7faa27a5135c0d12c63ec0947a21de46e190ccd.tar.gz reaction-d7faa27a5135c0d12c63ec0947a21de46e190ccd.zip |
added can_apply
Diffstat (limited to 'lib/Reaction/InterfaceModel')
-rw-r--r-- | lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm b/lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm index a204c7b..43d1927 100644 --- a/lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm +++ b/lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm @@ -12,16 +12,14 @@ has confirmation_code => has 'user' => ( is => 'rw', metaclass => 'Reaction::Meta::Attribute', + predicate => 'has_user', ); -around error_for_attribute => sub { - my $super = shift; - my ($self, $attr) = @_; - if ($attr->name eq 'confirmation_code') { - return "Confirmation code incorrect" - unless $self->verify_confirmation_code; - } - #return $super->(@_); #commented out because the original didn't super() +around can_apply => sub { + my $super = shift; + my ($self) = @_; + return 0 unless $self->verify_confirmation_code; + return $super->(@_); }; sub verify_confirmation_code { @@ -37,6 +35,15 @@ sub verify_confirmation_code { } } +around error_for_attribute => sub { + my $super = shift; + my ($self, $attr) = @_; + if ($attr->name eq 'confirmation_code') { + return 'Confirmation code incorrect' unless $self->has_user; + } + return $super->(@_); +}; + sub do_apply { my $self = shift; return $self->user->reset_password($self->new_password); |