</class>
<class id="aupsd" controller="open-ils.cstore" oils_obj:fieldmapper="actor::usr_password_set_date" reporter:label="User Password Set Date" oils_persist:readonly="true">
<oils_persist:source_definition><![CDATA[
- SELECT usr,create_date,edit_date FROM actor.passwd
+ SELECT ac.id, ac.usr as usr, au.home_ou as home_ou, ac.create_date as create_date, ac.edit_date as edit_date
+ FROM actor.passwd ac
+ JOIN actor.usr au on au.id = ac.usr
]]></oils_persist:source_definition>
<fields oils_persist:primary="id">
<field reporter:label="User ID" name="usr" reporter:datatype="id" />
+ <field reporter:label="User Home OU" name="home_ou" reporter:datatype="id" />
<field reporter:label="Create Date" name="create_date" reporter:datatype="timestamp"/>
<field reporter:label="Last Edit Date" name="edit_date" reporter:datatype="timestamp"/>
</fields>
<links>
<link field="usr" reltype="has_a" key="id" map="" class="au"/>
+ <link field="home_ou" reltype="has_a" key="id" map="" class="aou"/>
</links>
</class>
<class id="aupr" controller="open-ils.cstore" oils_obj:fieldmapper="actor::usr_password_reset" oils_persist:tablename="actor.usr_password_reset" reporter:label="User password reset requests">
my $old_patron;
my $barred_hook = '';
my $renew_hook = '';
- my $password_hook = '';
if($patron->isnew()) {
( $new_patron, $evt ) = _add_patron($e, _clone_patron($patron));
modify_migrated_user_password($e, $patron->id, $patron->passwd);
$new_patron->passwd(''); # subsequent update will set
# actor.usr.passwd to MD5('')
- #$U->create_events_for_hook('au.passwd_changed', $db_user, $e->requestor->ws_ou);
- $password_hook = 'au.passwd_changed';
}
}
$tses->request('open-ils.trigger.event.autocreate', $barred_hook,
$new_patron, $new_patron->home_ou) if $barred_hook;
-
- $tses->request('open-ils.trigger.event.autocreate', $password_hook,
- $new_patron, $new_patron->home_ou) if $password_hook;
}
$e->xact_begin; # $e->rollback is called in new_flesh_user
# would be required. Noting here for future reference.
modify_migrated_user_password($e, $db_user->id, $new_val);
$db_user->passwd('');
- $U->create_events_for_hook('au.passwd_changed', $db_user, $e->requestor->ws_ou);
+
} else {
# if we don't clear the password, the user will be updated with
# All is well; update the password
modify_migrated_user_password($e, $user->id, $password);
- $U->create_events_for_hook('au.passwd_changed', $user, $user->home_ou);
-
+
# And flag that this password reset request has been honoured
$aupr->[0]->has_been_reset('t');
$e->update_actor_usr_password_reset($aupr->[0]);
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.
);
INSERT INTO action_trigger.hook (key,core_type,description,passive) VALUES (
- 'au.passwd_changed',
- 'au',
- 'An account password was updated',
- false
+ 'aupsd.passwd_changed',
+ 'aupsd',
+ oils_i18n_gettext(
+ 'au.passwd_changed',
+ 'An account password was updated',
+ 'ath',
+ 'description'
+ ),
+ true
);
-INSERT INTO action_trigger.validator (module, description) VALUES (
- 'PatronOldPassword', 'Confirm that the patron has not updated their password since this event was created.'
+-- Sample Password Update Notice --
+
+INSERT INTO action_trigger.event_definition (active, owner, name, delay_field, delay, max_delay, repeat_delay, hook, validator, reactor, template)
+ VALUES ('f', 1, 'Password Update Notice', 'edit_date','90 days', '91 days','90 days' 'aupsd.passwd_changed', 'NOOP_True', 'SendEmail',
+$$
+[%- USE date -%]
+[%- user = target.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender || helpers.get_org_setting(user.home_ou, 'org.bounced_emails') %]
+Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
+Subject: Password Update Required
+Auto-Submitted: auto-generated
+
+Dear [% user.family_name %], [% user.first_given_name %]
+Regularly updating your password is an essential part of maintaining the security of your account. At the time of writing, your password is 90 days old. Please log in to the system or contact a system administrator to update your password.
+
+$$);
+
+INSERT INTO action_trigger.environment (
+ event_def,
+ path
+) VALUES (
+ currval('action_trigger.event_definition_id_seq'),
+ 'usr'
);
------------------- Disabled example A/T defintions ------------------------------
BEGIN;
---SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version);
+--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-- password age display setting
);
INSERT INTO action_trigger.hook (key,core_type,description,passive) VALUES (
- 'au.passwd_changed',
- 'au',
- 'An account password was updated',
- false
+ 'aupsd.passwd_changed',
+ 'aupsd',
+ oils_i18n_gettext(
+ 'au.passwd_changed',
+ 'An account password was updated',
+ 'ath',
+ 'description'
+ ),
+ true
);
-INSERT INTO action_trigger.validator (module, description) VALUES (
- 'PatronOldPassword', 'Confirm that the patron has not updated their password since this event was created.'
-);
+-- Sample Password Update Notice --
+
+INSERT INTO action_trigger.event_definition (active, owner, name, delay_field, delay, max_delay, repeat_delay, hook, validator, reactor, template)
+ VALUES ('f', 1, 'Password Update Notice', 'edit_date','90 days', '91 days','90 days' 'aupsd.passwd_changed', 'NOOP_True', 'SendEmail',
+$$
+[%- USE date -%]
+[%- user = target.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender || helpers.get_org_setting(user.home_ou, 'org.bounced_emails') %]
+Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
+Subject: Password Update Required
+Auto-Submitted: auto-generated
+
+Dear [% user.family_name %], [% user.first_given_name %]
+Regularly updating your password is an essential part of maintaining the security of your account. At the time of writing, your password is 90 days old. Please log in to the system or contact a system administrator to update your password.
+$$);
+
+INSERT INTO action_trigger.environment (
+ event_def,
+ path
+) VALUES (
+ currval('action_trigger.event_definition_id_seq'),
+ 'usr'
+);
--ROLLBACK;
COMMIT;
\ No newline at end of file