From 70408a6632bd1ffd410edeb29cd0d7379cbeb240 Mon Sep 17 00:00:00 2001 From: Jean-Roch Maitre Date: Mon, 7 Nov 2016 11:17:45 -0800 Subject: [PATCH] UI-2332: admins can now send reset password messages to their users --- i18n/en-US.json | 11 +++++++++-- submodules/users/users.js | 32 ++++++++++++++++++++++++++++++++ views/users-changePassword.html | 3 +++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/i18n/en-US.json b/i18n/en-US.json index ab15550..110c0ca 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -421,7 +421,11 @@ "password": "Password", "passwordPlaceholder": "Password (Min. 6 characters)", "title": "Update Email and password", - "username": "User's Email address" + "username": "User's Email address", + "resetPassword": { + "linkTitle": "here", + "text": "If you want the system to send an e-mail to this user with instructions on how to reset his password, click " + } }, "dialogChangePin": { "help": "You can use this popup to set a temporary PIN for a user that lost his PIN for example.", @@ -519,7 +523,10 @@ "pinUpdated": "You successfully updated the PIN of {{ name }}.", "__comment": "UI-1033: Now properly remove the Caller-ID Feature if we remove a number that was set as that Caller-ID Number", "__version": "3.20", - "callerIDDeleted": "The Caller-ID Number of this user was set to a number that was no longer assigned to him, so we disabled the Caller-ID Feature." + "callerIDDeleted": "The Caller-ID Number of this user was set to a number that was no longer assigned to him, so we disabled the Caller-ID Feature.", + "__comment": ": Now offer admin the option to send an email to reset the password of a user", + "__version": "4.0", + "successResetPassword": "Success! {{ name }} will be receiving an e-mail with instructions on how to reset his password shortly." }, "uploadPicture": "Upload a Picture", "user": "User", diff --git a/submodules/users/users.js b/submodules/users/users.js index d993d4b..82fc66f 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -908,6 +908,19 @@ define(function(require){ } }); + passwordTemplate.find('.reset-password').on('click', function() { + var dataReset = { + username: currentUser.username, + account_name: monster.apps.auth.currentAccount.name + }; + + self.usersResetPassword(dataReset, function() { + popup.dialog('close').remove(); + + toastr.success(monster.template(self, '!' + toastrMessages.successResetPassword, { name: dataReset.username })); + }); + }); + passwordTemplate.find('.save-new-username').on('click', function() { var formData = monster.ui.getFormData('form_new_username'), userToSave = $.extend(true, {}, currentUser, formData); @@ -4468,6 +4481,25 @@ define(function(require){ usersRemoveOverlay: function() { $('body').find('#users_container_overlay').remove(); + }, + + usersResetPassword: function(data, callback) { + var self = this, + dataPassword = { + username: data.username, + account_name: data.account_name, + ui_url: window.location.href.split('#')[0] + }; + + self.callApi({ + resource: 'auth.recovery', + data: { + data: dataPassword + }, + success: function(data) { + callback && callback(data.data); + } + }); } }; diff --git a/views/users-changePassword.html b/views/users-changePassword.html index d7d01c1..1adb545 100644 --- a/views/users-changePassword.html +++ b/views/users-changePassword.html @@ -16,6 +16,9 @@ {{#monsterText}} {{i18n.users.dialogChangePassword.help}} +

+ {{i18n.users.dialogChangePassword.resetPassword.text}} + {{i18n.users.dialogChangePassword.resetPassword.linkTitle}}. {{/monsterText}}