mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Issue #16411. Adding support for additional Hash algorithms specified by user in the UserRecord.
This commit is contained in:
@@ -9,6 +9,7 @@ namespace Orchard.Users.Models {
|
||||
|
||||
public virtual string Password { get; set; }
|
||||
public virtual MembershipPasswordFormat PasswordFormat { get; set; }
|
||||
public virtual string HashAlgorithm { get; set; }
|
||||
public virtual string PasswordSalt { get; set; }
|
||||
}
|
||||
}
|
@@ -39,6 +39,7 @@ namespace Orchard.Users.Services {
|
||||
init.Record.UserName = createUserParams.Username;
|
||||
init.Record.Email = createUserParams.Email;
|
||||
init.Record.NormalizedUserName = createUserParams.Username.ToLower();
|
||||
init.Record.HashAlgorithm = "SHA1";
|
||||
SetPassword(init.Record, createUserParams.Password);
|
||||
});
|
||||
}
|
||||
@@ -124,7 +125,7 @@ namespace Orchard.Users.Services {
|
||||
|
||||
var combinedBytes = saltBytes.Concat(passwordBytes).ToArray();
|
||||
|
||||
var hashAlgorithm = HashAlgorithm.Create("SHA1");
|
||||
var hashAlgorithm = HashAlgorithm.Create(record.HashAlgorithm);
|
||||
var hashBytes = hashAlgorithm.ComputeHash(combinedBytes);
|
||||
|
||||
record.PasswordFormat = MembershipPasswordFormat.Hashed;
|
||||
@@ -140,7 +141,7 @@ namespace Orchard.Users.Services {
|
||||
|
||||
var combinedBytes = saltBytes.Concat(passwordBytes).ToArray();
|
||||
|
||||
var hashAlgorithm = HashAlgorithm.Create("SHA1");
|
||||
var hashAlgorithm = HashAlgorithm.Create(record.HashAlgorithm);
|
||||
var hashBytes = hashAlgorithm.ComputeHash(combinedBytes);
|
||||
|
||||
return record.Password == Convert.ToBase64String(hashBytes);
|
||||
|
Reference in New Issue
Block a user