From 52a814188300514d93cbd512c4324218d0fc9824 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 Signed-off-by: Terran McCanna Signed-off-by: Galen Charlton --- .../src/templates/staff/circ/patron/index.tt2 | 6 ++++ .../templates/staff/circ/patron/t_edit.tt2 | 3 ++ .../js/ui/default/staff/circ/patron/regctl.js | 34 ++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/index.tt2 index d82b70e2b7..b5b92f42ec 100644 --- a/Open-ILS/src/templates/staff/circ/patron/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/index.tt2 @@ -51,6 +51,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 c92edb8e44..5112adfd74 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 @@ -220,6 +220,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 d80385cc4a..898f73294c 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 @@ -1266,7 +1275,7 @@ angular.module('egCoreMod') .controller('PatronRegCtrl', ['$scope','$routeParams','$q','$uibModal','$window','egCore', 'patronSvc','patronRegSvc','egUnloadPrompt','egAlertDialog', - 'egWorkLog', '$timeout','ngToast', + 'egWorkLog', '$timeout', 'ngToast', function($scope , $routeParams , $q , $uibModal , $window , egCore , patronSvc , patronRegSvc , egUnloadPrompt, egAlertDialog , egWorkLog, $timeout, ngToast) { @@ -1608,6 +1617,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.43.2