From: dbs Date: Wed, 14 Apr 2010 04:16:44 +0000 (+0000) Subject: Guard against 0 active requests (which otherwise results in an ugly error) X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=01d3f64aad4c1f96313d06526e8067846c6f6266;p=Evergreen.git Guard against 0 active requests (which otherwise results in an ugly error) git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@16234 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 3c2b9cbf52..0687e28ff3 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -3422,15 +3422,18 @@ sub _reset_password_request { } }); - my $last_request = DateTime::Format::ISO8601->parse_datetime(clense_ISO8601($active_requests->[0]->{'request_time'})); - my $now = DateTime::Format::ISO8601->new(); - - # 3. if (num_active > throttle_threshold) and (now - last_request < 1 minute) - if (($active_requests->[0]->{'usr'} > $aupr_throttle) && - ($last_request->add_duration('1 minute') > $now)) { - $cache->put_cache('open-ils.actor.password.throttle', DateTime::Format::ISO8601->new(), 60); - $e->die_event; - return OpenILS::Event->new('PATRON_TOO_MANY_ACTIVE_PASSWORD_RESET_REQUESTS'); + # Guard against no active requests + if ($active_requests->[0]->{'request_time'}) { + my $last_request = DateTime::Format::ISO8601->parse_datetime(clense_ISO8601($active_requests->[0]->{'request_time'})); + my $now = DateTime::Format::ISO8601->new(); + + # 3. if (num_active > throttle_threshold) and (now - last_request < 1 minute) + if (($active_requests->[0]->{'usr'} > $aupr_throttle) && + ($last_request->add_duration('1 minute') > $now)) { + $cache->put_cache('open-ils.actor.password.throttle', DateTime::Format::ISO8601->new(), 60); + $e->die_event; + return OpenILS::Event->new('PATRON_TOO_MANY_ACTIVE_PASSWORD_RESET_REQUESTS'); + } } # TODO Check to see if the user is in a password-reset-restricted group