From 39800262d06dfac14e80fcd10ff5e0dd0c01b52a Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Tue, 26 Mar 2019 17:14:00 -0400 Subject: [PATCH] LP#1264746 Add "email password reset" to user editor Add a button for "Send Password Reset Link" to the user editor. Signed-off-by: Jeff Godin --- Open-ILS/src/templates/staff/circ/patron/index.tt2 | 6 ++++ .../src/templates/staff/circ/patron/t_edit.tt2 | 3 ++ .../web/js/ui/default/staff/circ/patron/regctl.js | 36 ++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/index.tt2 index 5ebbe0eb9b..9b4fdc01ab 100644 --- a/Open-ILS/src/templates/staff/circ/patron/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/index.tt2 @@ -50,6 +50,12 @@ angular.module('egCoreMod').run(['egStrings', function(s) { s.CHECK_IN_CONFIRM = "[% l('Check In Items?') %]"; s.REG_INVALID_FIELDS = "[% l('Please enter valid values for all required fields.') %]" + s.REG_PASSWORD_RESET_REQUEST_NO_EMAIL = + "[% l('An email address is required for a password reset link to be sent.') %]"; + s.REG_PASSWORD_RESET_REQUEST_DIFFERENT_EMAIL = + "[% l('Patron email address appears to have been changed but not yet saved. Please save user before attempting to send password reset link.') %]"; + s.REG_PASSWORD_RESET_REQUEST_SUCCESSFUL = + "[% l('Submitted request for password reset link to be sent via email.') %]"; s.PAYMENT_WARN_AMOUNT = "[% l('Are you sure you want to apply a payment of $[_1]?', '{{payment_amount}}') %]"; s.PAYMENT_WARN_AMOUNT_TITLE = "[% l('Verify Payment Amount') %]"; s.PAYMENT_OVER_MAX = "[% l('Payments over $[_1] are denied by policy.', '{{max_amount}}') %]"; 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 f61f5eea07..60dec883d8 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 @@ -213,6 +213,9 @@ within the "form" by name for validation.
+
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js index e33933acb3..c0104b495a 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js @@ -164,6 +164,15 @@ angular.module('egCoreMod') egCore.auth.token(), usrname); } + // compare string with email address of loaded user, return true if different + service.check_email_different = function(email) { + if (service.existing_patron) { + if (email != service.existing_patron.email()) { + return $q.when(true); + } + } + } + //service.check_grp_app_perm = function(grp_id) { // determine which user groups our user is not allowed to modify @@ -1247,10 +1256,10 @@ angular.module('egCoreMod') .controller('PatronRegCtrl', ['$scope','$routeParams','$q','$uibModal','$window','egCore', 'patronSvc','patronRegSvc','egUnloadPrompt','egAlertDialog', - 'egWorkLog', '$timeout', + 'egWorkLog', '$timeout', 'ngToast', function($scope , $routeParams , $q , $uibModal , $window , egCore , patronSvc , patronRegSvc , egUnloadPrompt, egAlertDialog , - egWorkLog, $timeout) { + egWorkLog, $timeout, ngToast) { $scope.page_data_loaded = false; $scope.hold_notify_type = { phone : null, email : null, sms : null }; @@ -1549,6 +1558,29 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore , $scope.patron.passwd = Math.floor(Math.random()*9000) + 1000; } + $scope.send_password_reset_link = function() { + if (!$scope.patron.email || $scope.patron.email == '') { + egAlertDialog.open(egCore.strings.REG_PASSWORD_RESET_REQUEST_NO_EMAIL); + return; + } else if (patronRegSvc.check_email_different($scope.patron.email)) { + egAlertDialog.open(egCore.strings.REG_PASSWORD_RESET_REQUEST_DIFFERENT_EMAIL); + return; + } + // we have an email address, fire the reset request + egCore.net.request( + 'open-ils.actor', + 'open-ils.actor.patron.password_reset.request', + 'barcode', $scope.patron.card.barcode, $scope.patron.email + ).then(function(resp) { + if (resp == '1') { // request okay + ngToast.success(egCore.strings.REG_PASSWORD_RESET_REQUEST_SUCCESSFUL); + } else { + var evt = egCore.evt.parse(resp); + egAlertDialog.open(evt.desc); + } + }); + } + $scope.set_expire_date = function() { if (!$scope.patron.profile) return; var seconds = egCore.date.intervalToSeconds( -- 2.11.0