Rollback of changes not related to this issue

This commit is contained in:
Bjarke Berg
2020-03-24 19:37:04 +01:00
parent e8095b1a36
commit 9cca16d31b

View File

@@ -56,7 +56,22 @@ namespace Umbraco.Web.Install.InstallSteps
throw new InvalidOperationException("Could not find the super user!");
}
await ResetAdminPassword(user.Password);
var userManager = _httpContextAccessor.GetRequiredHttpContext().GetOwinContext().GetBackOfficeUserManager();
var membershipUser = await userManager.FindByIdAsync(Constants.Security.SuperUserId);
if (membershipUser == null)
{
throw new InvalidOperationException(
$"No user found in membership provider with id of {Constants.Security.SuperUserId}.");
}
//To change the password here we actually need to reset it since we don't have an old one to use to change
var resetToken = await userManager.GeneratePasswordResetTokenAsync(membershipUser.Id);
var resetResult =
await userManager.ChangePasswordWithResetAsync(membershipUser.Id, resetToken, user.Password.Trim());
if (!resetResult.Succeeded)
{
throw new InvalidOperationException("Could not reset password: " + string.Join(", ", resetResult.Errors));
}
admin.Email = user.Email.Trim();
admin.Name = user.Name.Trim();
@@ -82,26 +97,6 @@ namespace Umbraco.Web.Install.InstallSteps
return null;
}
private async Task ResetAdminPassword(string clearTextPassword)
{
var userManager = _httpContextAccessor.GetRequiredHttpContext().GetOwinContext().GetBackOfficeUserManager();
var membershipUser = await userManager.FindByIdAsync(Constants.Security.SuperUserId);
if (membershipUser == null)
{
throw new InvalidOperationException(
$"No user found in membership provider with id of {Constants.Security.SuperUserId}.");
}
//To change the password here we actually need to reset it since we don't have an old one to use to change
var resetToken = await userManager.GeneratePasswordResetTokenAsync(membershipUser.Id);
var resetResult =
await userManager.ChangePasswordWithResetAsync(membershipUser.Id, resetToken, clearTextPassword.Trim());
if (!resetResult.Succeeded)
{
throw new InvalidOperationException("Could not reset password: " + string.Join(", ", resetResult.Errors));
}
}
/// <summary>
/// Return a custom view model for this step
/// </summary>