private void SaveCurrentPassword()
{
var oldPasswords = this.GetOldPasswords();
if (oldPasswords != null && oldPasswords.Count > 0)
{
// set oldpasswords if last password does not equal to current password
if (oldPasswords.OrderBy(k => k.ModificationDate).Last().Hash != this.PasswordHash)
oldPasswords.Add(new PasswordField.OldPasswordData { ModificationDate = DateTime.Now, Hash = this.PasswordHash });
}
else
{
if (this.PasswordHash != null)
{
oldPasswords = new List<PasswordField.OldPasswordData>();
oldPasswords.Add(new PasswordField.OldPasswordData { ModificationDate = DateTime.Now, Hash = this.PasswordHash });
}
}
var passwordHistoryFieldMaxLength = RepositoryConfiguration.PasswordHistoryFieldMaxLength;
while (passwordHistoryFieldMaxLength + 1 < oldPasswords.Count)
oldPasswords.RemoveAt(0);
this.SetOldPasswords(oldPasswords);
}