Restored ability to automatically migrate hashing algorithm (#8672)

This commit is contained in:
Matteo Piovanelli
2023-04-21 08:52:29 +02:00
committed by GitHub
parent ff70011b69
commit 882fb8eca5
3 changed files with 15 additions and 1 deletions

View File

@@ -150,7 +150,8 @@ namespace Orchard.Users.Services {
Password = user.Password,
HashAlgorithm = user.HashAlgorithm,
PasswordFormat = user.PasswordFormat,
PasswordSalt = user.PasswordSalt
PasswordSalt = user.PasswordSalt,
User = user
}, password)) {
validationErrors.Add(T("The username or e-mail or password provided is incorrect."));
return null;

View File

@@ -8,6 +8,7 @@ using System.Web.Helpers;
using System.Web.Security;
using Orchard.Environment.Configuration;
using Orchard.Security;
using Orchard.Users.Models;
namespace Orchard.Users.Services {
public class PasswordService : IPasswordService {
@@ -56,6 +57,12 @@ namespace Orchard.Users.Services {
if (String.IsNullOrEmpty(keepOldConfiguration) || keepOldConfiguration.Equals("false", StringComparison.OrdinalIgnoreCase)) {
context.HashAlgorithm = DefaultHashAlgorithm;
context.Password = PasswordExtensions.ComputeHashBase64(context.HashAlgorithm, saltBytes, plaintextPassword);
// Actually persist the migration of the algorithm
var pwdUser = context.User as UserPart;
if (pwdUser != null) {
pwdUser.HashAlgorithm = context.HashAlgorithm;
pwdUser.Password = context.Password;
}
}
}