Create entry history only if DB is open

Fix issues in entry field names
Entry field names cleanup and refactoring
This commit is contained in:
Geoffroy BONNEVILLE
2020-05-26 13:38:07 +02:00
parent 3ecee4a821
commit 0c70b5146f
9 changed files with 29 additions and 68 deletions

View File

@@ -248,15 +248,6 @@ namespace ModernKeePass.Infrastructure.KeePass
switch (fieldName)
{
case EntryFieldName.Title:
case EntryFieldName.UserName:
case EntryFieldName.Password:
case EntryFieldName.Notes:
case EntryFieldName.Url:
var stringValue = fieldValue == null ? string.Empty: fieldValue.ToString();
var unprotectedFieldValue = isProtected ? await _cryptography.UnProtect(stringValue) : stringValue;
pwEntry.Strings.Set(EntryFieldMapper.MapFieldToPwDef(fieldName), new ProtectedString(isProtected, unprotectedFieldValue));
break;
case EntryFieldName.HasExpirationDate:
pwEntry.Expires = (bool)fieldValue;
break;
@@ -273,9 +264,9 @@ namespace ModernKeePass.Infrastructure.KeePass
pwEntry.ForegroundColor = (Color)fieldValue;
break;
default:
var additionalStringValue = fieldValue == null ? string.Empty: fieldValue.ToString();
var unprotectedAdditionalFieldValue = isProtected ? await _cryptography.UnProtect(additionalStringValue) : additionalStringValue;
pwEntry.Strings.Set(fieldName, new ProtectedString(isProtected, unprotectedAdditionalFieldValue));
var stringValue = fieldValue == null ? string.Empty: fieldValue.ToString();
var unprotectedFieldValue = isProtected ? await _cryptography.UnProtect(stringValue) : stringValue;
pwEntry.Strings.Set(fieldName, new ProtectedString(isProtected, unprotectedFieldValue));
break;
}
}