Issue #16411. Adding support for additional Hash algorithms specified by user in the UserRecord.

This commit is contained in:
Andrew Ma
2010-04-24 17:01:11 -07:00
parent d4b79ea272
commit de4aacc5bc
2 changed files with 4 additions and 2 deletions

View File

@@ -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; }
}
}

View File

@@ -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);