validator for password update trigger
authorLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Wed, 27 Apr 2022 13:41:45 +0000 (09:41 -0400)
committerLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Wed, 4 May 2022 20:51:01 +0000 (16:51 -0400)
no password age reminder for new patrons

Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm
Open-ILS/src/templates/staff/circ/patron/t_edit.tt2

index ad4e4f4..6be4329 100644 (file)
@@ -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.
index d56e7c8..a08b05c 100644 (file)
@@ -222,7 +222,7 @@ within the "form" by name for validation.
       [% l('Generate Password') %]</button>
   </div>
 </div>
-<div class="row reg-field-row">
+<div class="row reg-field-row" ng-show="!patron.isnew">
     <div class="col-md-3">
     </div>
     <div class="col-md-9">