Merge pull request #6120 from umbraco/v8/bugfix/6099-member-password-reset
Fixes: Member password reset checkbox doesn't hide "new" and "confirm" password fields. #6099
This commit is contained in:
+156
-151
@@ -1,167 +1,172 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function ChangePasswordController($scope) {
|
function ChangePasswordController($scope) {
|
||||||
|
|
||||||
function resetModel(isNew) {
|
var vm = this;
|
||||||
//the model config will contain an object, if it does not we'll create defaults
|
|
||||||
//NOTE: We will not support doing the password regex on the client side because the regex on the server side
|
|
||||||
//based on the membership provider cannot always be ported to js from .net directly.
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
hasPassword: true/false,
|
|
||||||
requiresQuestionAnswer: true/false,
|
|
||||||
enableReset: true/false,
|
|
||||||
enablePasswordRetrieval: true/false,
|
|
||||||
minPasswordLength: 10
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$scope.showReset = false;
|
vm.$onInit = onInit;
|
||||||
|
vm.$onDestroy = onDestroy;
|
||||||
|
vm.doChange = doChange;
|
||||||
|
vm.cancelChange = cancelChange;
|
||||||
|
vm.showOldPass = showOldPass;
|
||||||
|
vm.showCancelBtn = showCancelBtn;
|
||||||
|
|
||||||
//set defaults if they are not available
|
var unsubscribe = [];
|
||||||
if ($scope.config.disableToggle === undefined) {
|
|
||||||
$scope.config.disableToggle = false;
|
function resetModel(isNew) {
|
||||||
}
|
//the model config will contain an object, if it does not we'll create defaults
|
||||||
if ($scope.config.hasPassword === undefined) {
|
//NOTE: We will not support doing the password regex on the client side because the regex on the server side
|
||||||
$scope.config.hasPassword = false;
|
//based on the membership provider cannot always be ported to js from .net directly.
|
||||||
}
|
/*
|
||||||
if ($scope.config.enablePasswordRetrieval === undefined) {
|
{
|
||||||
$scope.config.enablePasswordRetrieval = true;
|
hasPassword: true/false,
|
||||||
}
|
requiresQuestionAnswer: true/false,
|
||||||
if ($scope.config.requiresQuestionAnswer === undefined) {
|
enableReset: true/false,
|
||||||
$scope.config.requiresQuestionAnswer = false;
|
enablePasswordRetrieval: true/false,
|
||||||
}
|
minPasswordLength: 10
|
||||||
//don't enable reset if it is new - that doesn't make sense
|
}
|
||||||
if (isNew === "true") {
|
*/
|
||||||
$scope.config.enableReset = false;
|
|
||||||
}
|
vm.showReset = false;
|
||||||
else if ($scope.config.enableReset === undefined) {
|
|
||||||
$scope.config.enableReset = true;
|
//set defaults if they are not available
|
||||||
}
|
if (vm.config.disableToggle === undefined) {
|
||||||
|
vm.config.disableToggle = false;
|
||||||
if ($scope.config.minPasswordLength === undefined) {
|
}
|
||||||
$scope.config.minPasswordLength = 0;
|
if (vm.config.hasPassword === undefined) {
|
||||||
}
|
vm.config.hasPassword = false;
|
||||||
|
}
|
||||||
//set the model defaults
|
if (vm.config.enablePasswordRetrieval === undefined) {
|
||||||
if (!angular.isObject($scope.passwordValues)) {
|
vm.config.enablePasswordRetrieval = true;
|
||||||
//if it's not an object then just create a new one
|
}
|
||||||
$scope.passwordValues = {
|
if (vm.config.requiresQuestionAnswer === undefined) {
|
||||||
newPassword: null,
|
vm.config.requiresQuestionAnswer = false;
|
||||||
oldPassword: null,
|
}
|
||||||
reset: null,
|
//don't enable reset if it is new - that doesn't make sense
|
||||||
answer: null
|
if (isNew === "true") {
|
||||||
};
|
vm.config.enableReset = false;
|
||||||
}
|
}
|
||||||
else {
|
else if (vm.config.enableReset === undefined) {
|
||||||
//just reset the values
|
vm.config.enableReset = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm.config.minPasswordLength === undefined) {
|
||||||
|
vm.config.minPasswordLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//set the model defaults
|
||||||
|
if (!angular.isObject(vm.passwordValues)) {
|
||||||
|
//if it's not an object then just create a new one
|
||||||
|
vm.passwordValues = {
|
||||||
|
newPassword: null,
|
||||||
|
oldPassword: null,
|
||||||
|
reset: null,
|
||||||
|
answer: null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//just reset the values
|
||||||
|
|
||||||
|
if (!isNew) {
|
||||||
|
//if it is new, then leave the generated pass displayed
|
||||||
|
vm.passwordValues.newPassword = null;
|
||||||
|
vm.passwordValues.oldPassword = null;
|
||||||
|
}
|
||||||
|
vm.passwordValues.reset = null;
|
||||||
|
vm.passwordValues.answer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//the value to compare to match passwords
|
||||||
|
if (!isNew) {
|
||||||
|
vm.passwordValues.confirm = "";
|
||||||
|
}
|
||||||
|
else if (vm.passwordValues.newPassword && vm.passwordValues.newPassword.length > 0) {
|
||||||
|
//if it is new and a new password has been set, then set the confirm password too
|
||||||
|
vm.passwordValues.confirm = vm.passwordValues.newPassword;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isNew) {
|
|
||||||
//if it is new, then leave the generated pass displayed
|
|
||||||
$scope.passwordValues.newPassword = null;
|
|
||||||
$scope.passwordValues.oldPassword = null;
|
|
||||||
}
|
}
|
||||||
$scope.passwordValues.reset = null;
|
|
||||||
$scope.passwordValues.answer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//the value to compare to match passwords
|
//when the scope is destroyed we need to unsubscribe
|
||||||
if (!isNew) {
|
function onDestroy() {
|
||||||
$scope.passwordValues.confirm = "";
|
for (var u in unsubscribe) {
|
||||||
}
|
unsubscribe[u]();
|
||||||
else if ($scope.passwordValues.newPassword && $scope.passwordValues.newPassword.length > 0) {
|
}
|
||||||
//if it is new and a new password has been set, then set the confirm password too
|
}
|
||||||
$scope.passwordValues.confirm = $scope.passwordValues.newPassword;
|
|
||||||
}
|
function onInit() {
|
||||||
|
//listen for the saved event, when that occurs we'll
|
||||||
|
//change to changing = false;
|
||||||
|
unsubscribe.push($scope.$on("formSubmitted", function () {
|
||||||
|
if (vm.config.disableToggle === false) {
|
||||||
|
vm.changing = false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
unsubscribe.push($scope.$on("formSubmitting", function () {
|
||||||
|
//if there was a previously generated password displaying, clear it
|
||||||
|
if (vm.changing && vm.passwordValues) {
|
||||||
|
vm.passwordValues.generatedPassword = null;
|
||||||
|
}
|
||||||
|
else if (!vm.changing) {
|
||||||
|
//we are not changing, so the model needs to be null
|
||||||
|
vm.passwordValues = null;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
resetModel(vm.isNew);
|
||||||
|
|
||||||
|
//if there is no password saved for this entity , it must be new so we do not allow toggling of the change password, it is always there
|
||||||
|
//with validators turned on.
|
||||||
|
vm.changing = vm.config.disableToggle === true || !vm.config.hasPassword;
|
||||||
|
|
||||||
|
//we're not currently changing so set the model to null
|
||||||
|
if (!vm.changing) {
|
||||||
|
vm.passwordValues = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function doChange() {
|
||||||
|
resetModel();
|
||||||
|
vm.changing = true;
|
||||||
|
//if there was a previously generated password displaying, clear it
|
||||||
|
vm.passwordValues.generatedPassword = null;
|
||||||
|
vm.passwordValues.confirm = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
function cancelChange() {
|
||||||
|
vm.changing = false;
|
||||||
|
//set model to null
|
||||||
|
vm.passwordValues = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
function showOldPass() {
|
||||||
|
return vm.config.hasPassword &&
|
||||||
|
!vm.config.allowManuallyChangingPassword &&
|
||||||
|
!vm.config.enablePasswordRetrieval && !vm.showReset;
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: I don't think we need this or the cancel button, this can be up to the editor rendering this component
|
||||||
|
function showCancelBtn() {
|
||||||
|
return vm.config.disableToggle !== true && vm.config.hasPassword;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetModel($scope.isNew);
|
var component = {
|
||||||
|
templateUrl: 'views/components/users/change-password.html',
|
||||||
//if there is no password saved for this entity , it must be new so we do not allow toggling of the change password, it is always there
|
controller: ChangePasswordController,
|
||||||
//with validators turned on.
|
controllerAs: 'vm',
|
||||||
$scope.changing = $scope.config.disableToggle === true || !$scope.config.hasPassword;
|
bindings: {
|
||||||
|
isNew: "<",
|
||||||
//we're not currently changing so set the model to null
|
passwordValues: "=", //TODO: Do we need bi-directional vals?
|
||||||
if (!$scope.changing) {
|
config: "=" //TODO: Do we need bi-directional vals?
|
||||||
$scope.passwordValues = null;
|
//TODO: Do we need callbacks?
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.doChange = function () {
|
|
||||||
resetModel();
|
|
||||||
$scope.changing = true;
|
|
||||||
//if there was a previously generated password displaying, clear it
|
|
||||||
$scope.passwordValues.generatedPassword = null;
|
|
||||||
$scope.passwordValues.confirm = null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.cancelChange = function () {
|
angular.module('umbraco.directives').component('changePassword', component);
|
||||||
$scope.changing = false;
|
|
||||||
//set model to null
|
|
||||||
$scope.passwordValues = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
var unsubscribe = [];
|
|
||||||
|
|
||||||
//listen for the saved event, when that occurs we'll
|
|
||||||
//change to changing = false;
|
|
||||||
unsubscribe.push($scope.$on("formSubmitted", function () {
|
|
||||||
if ($scope.config.disableToggle === false) {
|
|
||||||
$scope.changing = false;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
unsubscribe.push($scope.$on("formSubmitting", function () {
|
|
||||||
//if there was a previously generated password displaying, clear it
|
|
||||||
if ($scope.changing && $scope.passwordValues) {
|
|
||||||
$scope.passwordValues.generatedPassword = null;
|
|
||||||
}
|
|
||||||
else if (!$scope.changing) {
|
|
||||||
//we are not changing, so the model needs to be null
|
|
||||||
$scope.passwordValues = null;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
//when the scope is destroyed we need to unsubscribe
|
|
||||||
$scope.$on('$destroy', function () {
|
|
||||||
for (var u in unsubscribe) {
|
|
||||||
unsubscribe[u]();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.showOldPass = function () {
|
|
||||||
return $scope.config.hasPassword &&
|
|
||||||
!$scope.config.allowManuallyChangingPassword &&
|
|
||||||
!$scope.config.enablePasswordRetrieval && !$scope.showReset;
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: I don't think we need this or the cancel button, this can be up to the editor rendering this directive
|
|
||||||
$scope.showCancelBtn = function () {
|
|
||||||
return $scope.config.disableToggle !== true && $scope.config.hasPassword;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function ChangePasswordDirective() {
|
|
||||||
|
|
||||||
var directive = {
|
|
||||||
restrict: 'E',
|
|
||||||
replace: true,
|
|
||||||
templateUrl: 'views/components/users/change-password.html',
|
|
||||||
controller: 'Umbraco.Editors.Users.ChangePasswordDirectiveController',
|
|
||||||
scope: {
|
|
||||||
isNew: "=?",
|
|
||||||
passwordValues: "=",
|
|
||||||
config: "="
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return directive;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module('umbraco.directives').controller('Umbraco.Editors.Users.ChangePasswordDirectiveController', ChangePasswordController);
|
|
||||||
angular.module('umbraco.directives').directive('changePassword', ChangePasswordDirective);
|
|
||||||
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
|
|||||||
var savedVariants = [];
|
var savedVariants = [];
|
||||||
if (origContent.variants) {
|
if (origContent.variants) {
|
||||||
isContent = true;
|
isContent = true;
|
||||||
//it's contnet so assign the variants as they exist
|
//it's content so assign the variants as they exist
|
||||||
origVariants = origContent.variants;
|
origVariants = origContent.variants;
|
||||||
savedVariants = savedContent.variants;
|
savedVariants = savedContent.variants;
|
||||||
}
|
}
|
||||||
@@ -510,7 +510,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
|
|||||||
|
|
||||||
//special case for content, don't sync this variant if it wasn't tagged
|
//special case for content, don't sync this variant if it wasn't tagged
|
||||||
//for saving in the first place
|
//for saving in the first place
|
||||||
if (!origVariant.save) {
|
if (isContent && !origVariant.save) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,68 +1,69 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="alert alert-success text-center" ng-hide="!passwordValues.generatedPassword">
|
<div class="alert alert-success text-center" ng-hide="!vm.passwordValues.generatedPassword">
|
||||||
<small>Password has been reset to:</small>
|
<small>Password has been reset to:</small>
|
||||||
<br />
|
<br />
|
||||||
<strong>{{passwordValues.generatedPassword}}</strong>
|
<strong>{{vm.passwordValues.generatedPassword}}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div ng-switch="changing">
|
<div ng-switch="vm.changing">
|
||||||
<div ng-switch-when="false">
|
<div ng-switch-when="false">
|
||||||
<a href="" ng-click="doChange()" class="btn btn-small">
|
<a href="" ng-click="vm.doChange()" class="btn btn-small">
|
||||||
<localize key="general_changePassword">Change password</localize>
|
<localize key="general_changePassword">Change password</localize>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div ng-switch-when="true">
|
<div ng-switch-when="true">
|
||||||
<ng-form name="passwordForm">
|
|
||||||
<umb-control-group alias="resetPassword" label="@user_resetPassword" ng-show="config.enableReset">
|
<ng-form name="vm.passwordForm">
|
||||||
<input type="checkbox" ng-model="passwordValues.reset"
|
<umb-control-group alias="resetPassword" label="@user_resetPassword" ng-show="vm.config.enableReset">
|
||||||
|
<input type="checkbox" ng-model="vm.passwordValues.reset"
|
||||||
id="Checkbox1"
|
id="Checkbox1"
|
||||||
name="resetPassword"
|
name="resetPassword"
|
||||||
val-server-field="resetPassword"
|
val-server-field="resetPassword"
|
||||||
no-dirty-check
|
no-dirty-check
|
||||||
ng-change="showReset = !showReset" />
|
ng-change="vm.showReset = !vm.showReset" />
|
||||||
<span ng-messages="passwordForm.resetPassword.$error" show-validation-on-submit >
|
<span ng-messages="vm.passwordForm.resetPassword.$error" show-validation-on-submit>
|
||||||
<span class="help-inline" ng-message="valServerField">{{passwordForm.resetPassword.errorMsg}}</span>
|
<span class="help-inline" ng-message="valServerField">{{vm.passwordForm.resetPassword.errorMsg}}</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</umb-control-group>
|
</umb-control-group>
|
||||||
|
|
||||||
<!-- we need to show the old pass field when the provider cannot retrieve the password -->
|
<!-- we need to show the old pass field when the provider cannot retrieve the password -->
|
||||||
<umb-control-group alias="oldPassword" label="@user_oldPassword" ng-if="showOldPass()" required="true">
|
<umb-control-group alias="oldPassword" label="@user_oldPassword" ng-if="vm.showOldPass()" required="true">
|
||||||
<input type="password" name="oldPassword" ng-model="passwordValues.oldPassword"
|
<input type="password" name="oldPassword" ng-model="vm.passwordValues.oldPassword"
|
||||||
class="input-block-level umb-textstring textstring"
|
class="input-block-level umb-textstring textstring"
|
||||||
required
|
required
|
||||||
val-server-field="oldPassword"
|
val-server-field="oldPassword"
|
||||||
no-dirty-check />
|
no-dirty-check />
|
||||||
<span ng-messages="passwordForm.oldPassword.$error" show-validation-on-submit >
|
<span ng-messages="vm.passwordForm.oldPassword.$error" show-validation-on-submit>
|
||||||
<span class="help-inline" ng-message="required">Required</span>
|
<span class="help-inline" ng-message="required">Required</span>
|
||||||
<span class="help-inline" ng-message="valServerField">{{passwordForm.oldPassword.errorMsg}}</span>
|
<span class="help-inline" ng-message="valServerField">{{vm.passwordForm.oldPassword.errorMsg}}</span>
|
||||||
</span>
|
</span>
|
||||||
</umb-control-group>
|
</umb-control-group>
|
||||||
|
|
||||||
<umb-control-group alias="password" label="@user_newPassword" ng-if="!showReset" required="true">
|
<umb-control-group alias="password" label="@user_newPassword" ng-if="!vm.showReset" required="true">
|
||||||
<input type="password" name="password" ng-model="passwordValues.newPassword"
|
<input type="password" name="password" ng-model="vm.passwordValues.newPassword"
|
||||||
class="input-block-level umb-textstring textstring"
|
class="input-block-level umb-textstring textstring"
|
||||||
required
|
required
|
||||||
val-server-field="password"
|
val-server-field="password"
|
||||||
ng-minlength="{{config.minPasswordLength}}"
|
ng-minlength="{{vm.config.minPasswordLength}}"
|
||||||
no-dirty-check />
|
no-dirty-check />
|
||||||
<span ng-messages="passwordForm.password.$error" show-validation-on-submit >
|
<span ng-messages="vm.passwordForm.password.$error" show-validation-on-submit>
|
||||||
<span class="help-inline" ng-message="required">Required</span>
|
<span class="help-inline" ng-message="required">Required</span>
|
||||||
<span class="help-inline" ng-message="minlength">Minimum {{config.minPasswordLength}} characters</span>
|
<span class="help-inline" ng-message="minlength">Minimum {{vm.config.minPasswordLength}} characters</span>
|
||||||
<span class="help-inline" ng-message="valServerField">{{passwordForm.password.errorMsg}}</span>
|
<span class="help-inline" ng-message="valServerField">{{vm.passwordForm.password.errorMsg}}</span>
|
||||||
</span>
|
</span>
|
||||||
</umb-control-group>
|
</umb-control-group>
|
||||||
|
|
||||||
<umb-control-group alias="confirmpassword" label="@user_confirmNewPassword" ng-if="!showReset" required="true">
|
<umb-control-group alias="confirmpassword" label="@user_confirmNewPassword" ng-if="!vm.showReset" required="true">
|
||||||
<input type="password" name="confirmpassword" ng-model="passwordValues.confirm"
|
<input type="password" name="confirmpassword" ng-model="vm.passwordValues.confirm"
|
||||||
class="input-block-level umb-textstring textstring"
|
class="input-block-level umb-textstring textstring"
|
||||||
val-compare="password"
|
val-compare="password"
|
||||||
no-dirty-check />
|
no-dirty-check />
|
||||||
<span ng-messages="passwordForm.confirmpassword.$error" show-validation-on-submit >
|
<span ng-messages="vm.passwordForm.confirmpassword.$error" show-validation-on-submit>
|
||||||
<span class="help-inline" ng-message="valCompare"><localize key="user_passwordMismatch">The confirmed password doesn't match the new password!</localize></span>
|
<span class="help-inline" ng-message="valCompare"><localize key="user_passwordMismatch">The confirmed password doesn't match the new password!</localize></span>
|
||||||
</span>
|
</span>
|
||||||
</umb-control-group>
|
</umb-control-group>
|
||||||
|
|
||||||
<a href="" ng-click="cancelChange()" ng-show="showCancelBtn()" class="btn btn-small">
|
<a href="" ng-click="vm.cancelChange()" ng-show="vm.showCancelBtn()" class="btn btn-small">
|
||||||
<localize key="general_cancel">Cancel</localize>
|
<localize key="general_cancel">Cancel</localize>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user