Allow editing password entry label

This commit is contained in:
thePR0M3TH3AN
2025-07-05 15:29:19 -04:00
parent c52a8cc059
commit b23f4cbd00
3 changed files with 15 additions and 2 deletions

View File

@@ -521,7 +521,7 @@ class EntryManager:
:param url: (Optional) The new URL (password entries).
:param blacklisted: (Optional) The new blacklist status.
:param notes: (Optional) New notes to attach to the entry.
:param label: (Optional) The new label for TOTP entries.
:param label: (Optional) The new label for the entry.
:param period: (Optional) The new TOTP period in seconds.
:param digits: (Optional) The new number of digits for TOTP codes.
"""
@@ -554,6 +554,9 @@ class EntryManager:
entry["digits"] = digits
logger.debug(f"Updated digits to '{digits}' for index {index}.")
else:
if label is not None:
entry["label"] = label
logger.debug(f"Updated label to '{label}' for index {index}.")
if username is not None:
entry["username"] = username
logger.debug(f"Updated username to '{username}' for index {index}.")

View File

@@ -1665,7 +1665,7 @@ class PasswordManager:
custom_fields=custom_fields,
)
else:
website_name = entry.get("website")
website_name = entry.get("label", entry.get("website"))
username = entry.get("username")
url = entry.get("url")
blacklisted = entry.get("blacklisted")
@@ -1677,6 +1677,7 @@ class PasswordManager:
"cyan",
)
)
print(colored(f"Current Label: {website_name}", "cyan"))
print(colored(f"Current Username: {username or 'N/A'}", "cyan"))
print(colored(f"Current URL: {url or 'N/A'}", "cyan"))
print(
@@ -1686,6 +1687,13 @@ class PasswordManager:
)
)
new_label = (
input(
f'Enter new label (leave blank to keep "{website_name}"): '
).strip()
or website_name
)
new_username = (
input(
f'Enter new username (leave blank to keep "{username or "N/A"}"): '
@@ -1747,6 +1755,7 @@ class PasswordManager:
new_url,
new_blacklisted,
new_notes,
label=new_label,
custom_fields=custom_fields,
)

View File

@@ -57,6 +57,7 @@ def test_manager_workflow(monkeypatch):
"", # length (default)
"0", # retrieve index
"0", # modify index
"", # new label
"user", # new username
"", # new url
"", # blacklist status