From: Llewellyn Marshall Date: Wed, 27 Apr 2022 13:41:45 +0000 (-0400) Subject: validator for password update trigger X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b80b0b0ea54c570c7d3913fdedb3c68788732dea;p=working%2FEvergreen.git validator for password update trigger no password age reminder for new patrons --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm index ad4e4f4fb6..6be4329d76 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm @@ -166,6 +166,35 @@ sub PatronNotBarred { return !PatronBarred(@_); } +# returns invalid if the patron's password was updated in the time +# between now and the parent event being created +sub PatronOldPassword { + my ($self, $env) = @_; + my $event = $env->{event}; + # get add time of the event + my $add_time = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($event->add_time)); + # get the last time the user changed their password + my $aupsds = new_editor()->json_query({ + select => {aupsd => ['create_date','edit_date']}, + from => 'aupsd', + where => { + usr => $env->{target}->id + } + }); + + if(defined $aupsds){ + my $pwd = $aupsds->[0]; + #convert the dates with the DateTime module + if($pwd){ + my $edit_datetime = DateTime::Format::ISO8601->parse_datetime(clean_ISO8601($pwd->{'edit_date'})); + # if the change time is after the add time, return invalid + return $edit_datetime <= $add_time; + } + } + + return 1; +} + # core type "circ". # Being "In Collections" means having the PATRON_IN_COLLECTIONS penalty # applied to the user at or above the circ_lib of the target circ. diff --git a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 index d56e7c800f..a08b05c3bb 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 @@ -222,7 +222,7 @@ within the "form" by name for validation. [% l('Generate Password') %] -
+