Gets the user states set correctly

This commit is contained in:
Shannon
2017-06-23 15:14:46 +10:00
parent ea2f808c1e
commit d936105cfe
4 changed files with 29 additions and 15 deletions

View File

@@ -255,12 +255,17 @@ namespace Umbraco.Core.Models.Membership
public UserState UserState
{
get
{
{
if (LastLoginDate == default(DateTime) && IsApproved == false && InvitedDate != null)
return UserState.Invited;
if (LastLoginDate == default(DateTime) && InvitedDate == null && RawPasswordValue.StartsWith(Constants.Security.EmptyPasswordPrefix))
return UserState.NoCredentials;
if (IsLockedOut)
return UserState.LockedOut;
if (IsApproved == false)
return UserState.Disabled;
//TODO: Fill in the invite details
return UserState.Active;
}
}

View File

@@ -9,6 +9,11 @@
Active = 0,
Disabled = 1,
LockedOut = 2,
Invited = 3
Invited = 3,
/// <summary>
/// Occurs when the user has been created (not invited) and has no credentials assigned
/// </summary>
NoCredentials = 4
}
}

View File

@@ -139,6 +139,7 @@
return !$scope.passwordValues.reset;
};
//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;
};

View File

@@ -42,19 +42,22 @@
vm.user = user;
makeBreadcrumbs(vm.user);
setUserDisplayState();
vm.loading = false;
});
//go get the config for the membership provider and add it to the model
authResource.getMembershipProviderConfig().then(function (data) {
vm.changePasswordModel.config = data;
//ensure the hasPassword config option is set to true (the user of course has a password already assigned)
//this will ensure the oldPassword is shown so they can change it
// disable reset password functionality beacuse it does not make sense inside the backoffice
vm.changePasswordModel.config.hasPassword = true;
vm.changePasswordModel.config.disableToggle = true;
vm.changePasswordModel.config.enableReset = false;
});
//go get the config for the membership provider and add it to the model
authResource.getMembershipProviderConfig().then(function (data) {
vm.changePasswordModel.config = data;
//the user has a password if they are not states: Invited, NoCredentials
vm.changePasswordModel.config.hasPassword = vm.user.userState !== 3 && vm.user.userState !== 4;
vm.changePasswordModel.config.disableToggle = true;
// disable reset password functionality beacuse it does not make sense inside the backoffice
vm.changePasswordModel.config.enableReset = false;
vm.loading = false;
});
});
}
function toggleChangePassword() {