diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/user/user.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/user/user.controller.js index 7f9e546709..53c8b13bff 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/user/user.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/user/user.controller.js @@ -1,14 +1,12 @@ angular.module("umbraco") - .controller("Umbraco.Editors.UserController", function ($scope, $location, $timeout, + .controller("Umbraco.Editors.UserController", function ($scope, $location, dashboardResource, userService, historyService, eventsService, - externalLoginInfoService, authResource, - currentUserResource, formHelper, localizationService, editorService, twoFactorLoginResource) { + externalLoginInfoService, authResource, contentEditingHelper, + currentUserResource, overlayService, localizationService, editorService, twoFactorLoginResource) { let vm = this; vm.history = historyService.getCurrent(); - vm.showPasswordFields = false; - vm.changePasswordButtonState = "init"; vm.hasTwoFactorProviders = false; localizationService.localize("general_user").then(function (value) { @@ -51,20 +49,7 @@ angular.module("umbraco") $location.path(link); vm.close(); }; - /* - //Manually update the remaining timeout seconds - function updateTimeout() { - $timeout(function () { - if (vm.remainingAuthSeconds > 0) { - vm.remainingAuthSeconds--; - $scope.$digest(); - //recurse - updateTimeout(); - } - }, 1000, false); // 1 second, do NOT execute a global digest - } - */ function updateUserInfo() { //get the user userService.getCurrentUser().then(function (user) { @@ -72,8 +57,6 @@ angular.module("umbraco") if (vm.user) { vm.remainingAuthSeconds = vm.user.remainingAuthSeconds; vm.canEditProfile = _.indexOf(vm.user.allowedSections, "users") > -1; - //set the timer - //updateTimeout(); currentUserResource.getCurrentUserLinkedLogins().then(function (logins) { @@ -107,10 +90,20 @@ angular.module("umbraco") } }); - - } + function changePassword() { + return currentUserResource.changePassword(vm.changePasswordModel.value).then(function () { + return true; + }, function (err) { + contentEditingHelper.handleSaveError({ + err: err, + showNotifications: true + }); + return false; + }); + }; + vm.linkProvider = function (e) { e.target.submit(); } @@ -144,53 +137,40 @@ angular.module("umbraco") }); - vm.changePassword = function () { - - if (formHelper.submitForm({ scope: $scope })) { - - vm.changePasswordButtonState = "busy"; - - currentUserResource.changePassword(vm.changePasswordModel.value).then(function (data) { - - //reset old data - clearPasswordFields(); - - formHelper.resetForm({ scope: $scope }); - - vm.changePasswordButtonState = "success"; - $timeout(function () { - vm.togglePasswordFields(); - }, 2000); - - }, function (err) { - formHelper.resetForm({ scope: $scope, hasErrors: true }); - formHelper.handleError(err); - - vm.changePasswordButtonState = "error"; - - }); - - } - - }; - - vm.togglePasswordFields = function () { - clearPasswordFields(); - vm.showPasswordFields = !vm.showPasswordFields; - } - - function clearPasswordFields() { - vm.changePasswordModel.value.oldPassword = ""; - vm.changePasswordModel.value.newPassword = ""; - vm.changePasswordModel.value.confirm = ""; - } - vm.editUser = function () { $location .path('/users/users/user/' + vm.user.id); vm.close(); } + vm.toggleChangePassword = function () { + //reset it + vm.user.changePassword = null; + + localizationService.localizeMany(["general_cancel", "general_confirm", "general_changePassword"]) + .then(function (data) { + const overlay = { + view: "changepassword", + title: data[2], + changePassword: vm.user.changePassword, + config: vm.changePasswordModel.config, + closeButtonLabel: data[0], + submitButtonLabel: data[1], + submitButtonStyle: 'success', + close: () => overlayService.close(), + submit: model => { + vm.changePasswordModel.value = model.changePassword; + changePassword().then(result => { + if (result) { + overlayService.close(); + } + }); + } + }; + overlayService.open(overlay); + }); + } + vm.toggleConfigureTwoFactor = function () { const configureTwoFactorSettings = { diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/user/user.html b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/user/user.html index c67f65a7d2..ed8cbd13e0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/user/user.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/user/user.html @@ -16,7 +16,7 @@ label-key="general_edit" ng-if="vm.canEditProfile" type="button"> - @@ -91,29 +91,6 @@ -
- -
- Change password -
- -
- - - - - - - - - - -
- -
-
{{tab.label}}
diff --git a/src/Umbraco.Web.UI.Client/src/views/components/users/change-password.html b/src/Umbraco.Web.UI.Client/src/views/components/users/change-password.html index 81dd8d6fe8..74cba97696 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/users/change-password.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/users/change-password.html @@ -16,8 +16,9 @@ - @@ -28,8 +29,9 @@ - The confirmed password doesn't match the new password!