mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 15:58:48 +00:00
Add custom field support
This commit is contained in:
@@ -112,6 +112,7 @@ class EntryManager:
|
||||
url: Optional[str] = None,
|
||||
blacklisted: bool = False,
|
||||
notes: str = "",
|
||||
custom_fields: List[Dict[str, Any]] | None = None,
|
||||
) -> int:
|
||||
"""
|
||||
Adds a new entry to the encrypted JSON index file.
|
||||
@@ -138,6 +139,7 @@ class EntryManager:
|
||||
"type": EntryType.PASSWORD.value,
|
||||
"kind": EntryType.PASSWORD.value,
|
||||
"notes": notes,
|
||||
"custom_fields": custom_fields or [],
|
||||
}
|
||||
|
||||
logger.debug(f"Added entry at index {index}: {data['entries'][str(index)]}")
|
||||
@@ -414,6 +416,8 @@ class EntryManager:
|
||||
entry = data.get("entries", {}).get(str(index))
|
||||
|
||||
if entry:
|
||||
if entry.get("type", entry.get("kind")) == EntryType.PASSWORD.value:
|
||||
entry.setdefault("custom_fields", [])
|
||||
logger.debug(f"Retrieved entry at index {index}: {entry}")
|
||||
return entry
|
||||
else:
|
||||
@@ -441,6 +445,7 @@ class EntryManager:
|
||||
label: Optional[str] = None,
|
||||
period: Optional[int] = None,
|
||||
digits: Optional[int] = None,
|
||||
custom_fields: List[Dict[str, Any]] | None = None,
|
||||
) -> None:
|
||||
"""
|
||||
Modifies an existing entry based on the provided index and new values.
|
||||
@@ -500,6 +505,12 @@ class EntryManager:
|
||||
entry["notes"] = notes
|
||||
logger.debug(f"Updated notes for index {index}.")
|
||||
|
||||
if custom_fields is not None:
|
||||
entry["custom_fields"] = custom_fields
|
||||
logger.debug(
|
||||
f"Updated custom fields for index {index}: {custom_fields}"
|
||||
)
|
||||
|
||||
data["entries"][str(index)] = entry
|
||||
logger.debug(f"Modified entry at index {index}: {entry}")
|
||||
|
||||
@@ -629,11 +640,18 @@ class EntryManager:
|
||||
username = entry.get("username", "")
|
||||
url = entry.get("url", "")
|
||||
notes = entry.get("notes", "")
|
||||
custom_fields = entry.get("custom_fields", [])
|
||||
custom_match = any(
|
||||
query_lower in str(cf.get("label", "")).lower()
|
||||
or query_lower in str(cf.get("value", "")).lower()
|
||||
for cf in custom_fields
|
||||
)
|
||||
if (
|
||||
query_lower in website.lower()
|
||||
or query_lower in username.lower()
|
||||
or query_lower in url.lower()
|
||||
or query_lower in notes.lower()
|
||||
or custom_match
|
||||
):
|
||||
results.append(
|
||||
(
|
||||
|
Reference in New Issue
Block a user