diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/auth.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/auth.resource.js index 5de92527d3..4f95893490 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/auth.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/auth.resource.js @@ -200,7 +200,7 @@ function authResource($q, $http, umbRequestHelper, angularHelper) { if (!newPassword) { return angularHelper.rejectedPromise({ errorMsg: 'newPassword cannot be empty' }); - } + } return umbRequestHelper.resourcePromise( $http.post( @@ -209,6 +209,23 @@ function authResource($q, $http, umbRequestHelper, angularHelper) { "PostSetInvitedUserPassword"), angular.toJson(newPassword)), 'Failed to change password'); + }, + + /** + * @ngdoc method + * @name umbraco.resources.currentUserResource#getMembershipProviderConfig + * @methodOf umbraco.resources.currentUserResource + * + * @description + * Gets the configuration of the user membership provider which is used to configure the change password form + */ + getMembershipProviderConfig: function () { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "authenticationApiBaseUrl", + "GetMembershipProviderConfig")), + 'Failed to retrieve membership provider config'); }, /** diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js index 21f55dd6a1..fee8f34e41 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js @@ -29,24 +29,8 @@ function currentUserResource($q, $http, umbRequestHelper) { "PostChangePassword"), changePasswordArgs), 'Failed to change password'); - }, - - /** - * @ngdoc method - * @name umbraco.resources.currentUserResource#getMembershipProviderConfig - * @methodOf umbraco.resources.currentUserResource - * - * @description - * Gets the configuration of the user membership provider which is used to configure the change password form - */ - getMembershipProviderConfig: function () { - return umbRequestHelper.resourcePromise( - $http.get( - umbRequestHelper.getApiUrl( - "currentUserApiBaseUrl", - "GetMembershipProviderConfig")), - 'Failed to retrieve membership provider config'); - }, + } + }; } diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js index 229bc1047a..904ae58289 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js @@ -1,22 +1,43 @@ angular.module("umbraco").controller("Umbraco.Dialogs.LoginController", - function ($scope, $cookies, $location, currentUserResource, formHelper, localizationService, userService, externalLoginInfo, resetPasswordCodeInfo, $timeout, authResource, dialogService) { + function ($scope, $cookies, $location, currentUserResource, formHelper, localizationService, userService, externalLoginInfo, resetPasswordCodeInfo, $timeout, authResource, dialogService, $q) { $scope.invitedUser = null; $scope.invitedUserPasswordModel = { - password: "", - confirmPassword: "" + password: "", + confirmPassword: "", + buttonState: "", + passwordPolicies: null, + passwordPolicyText: "" } function init() { // Check if it is a new user if ($location.search().invite) { - - authResource.getCurrentInvitedUser().then(function (data) { - $scope.invitedUser = data; + + $q.all([ + //get the current invite user + authResource.getCurrentInvitedUser().then(function (data) { + $scope.invitedUser = data; + }, + function() { + //it failed so we should remove the search + $location.search('invite', null); + }), + //get the membership provider config for password policies + authResource.getMembershipProviderConfig().then(function (data) { + $scope.invitedUserPasswordModel.passwordPolicies = data; + + //localize the text + localizationService.localize("errorHandling_errorInPasswordFormat", + [ + $scope.invitedUserPasswordModel.passwordPolicies.minPasswordLength, + $scope.invitedUserPasswordModel.passwordPolicies.minNonAlphaNumericChars + ]).then(function(data) { + $scope.invitedUserPasswordModel.passwordPolicyText = data; + }); + }) + ]).then(function() { $scope.inviteSetPassword = true; - }, function () { - //it failed so we should remove the search - $location.search('invite', null); }); } } @@ -25,14 +46,14 @@ if (formHelper.submitForm({ scope: $scope, statusMessage: "Saving..." })) { - $scope.inviteChangePasswordButtonState = "busy"; + $scope.invitedUserPasswordModel.buttonState = "busy"; authResource.performSetInvitedUserPassword($scope.invitedUserPasswordModel.password) .then(function (data) { //success formHelper.resetForm({ scope: $scope, notifications: data.notifications }); - $scope.inviteChangePasswordButtonState = "success"; + $scope.invitedUserPasswordModel.buttonState = "success"; $scope.inviteSetPassword = false; $scope.inviteSetAvatar = true; @@ -42,7 +63,7 @@ //error formHelper.handleError(err); - $scope.inviteChangePasswordButtonState = "error"; + $scope.invitedUserPasswordModel.buttonState = "error"; }); } @@ -144,6 +165,8 @@ } $scope.loginSubmit = function (login, password) { + + //TODO: Do validation properly like in the invite password update //if the login and password are not empty we need to automatically // validate them - this is because if there are validation errors on the server @@ -195,6 +218,8 @@ $scope.requestPasswordResetSubmit = function (email) { + //TODO: Do validation properly like in the invite password update + if (email && email.length > 0) { $scope.requestPasswordResetForm.email.$setValidity('auth', true); } diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html index 059366659b..0fb7af2c42 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html @@ -18,10 +18,11 @@