mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 00:09:04 +00:00
store password hash in config
This commit is contained in:
@@ -37,7 +37,11 @@ class ConfigManager:
|
||||
"""
|
||||
if not self.config_path.exists():
|
||||
logger.info("Config file not found; returning defaults")
|
||||
return {"relays": list(DEFAULT_NOSTR_RELAYS), "pin_hash": ""}
|
||||
return {
|
||||
"relays": list(DEFAULT_NOSTR_RELAYS),
|
||||
"pin_hash": "",
|
||||
"password_hash": "",
|
||||
}
|
||||
try:
|
||||
data = self.vault.load_config()
|
||||
if not isinstance(data, dict):
|
||||
@@ -45,6 +49,14 @@ class ConfigManager:
|
||||
# Ensure defaults for missing keys
|
||||
data.setdefault("relays", list(DEFAULT_NOSTR_RELAYS))
|
||||
data.setdefault("pin_hash", "")
|
||||
data.setdefault("password_hash", "")
|
||||
|
||||
# Migrate legacy hashed_password.enc if present and password_hash is missing
|
||||
legacy_file = self.fingerprint_dir / "hashed_password.enc"
|
||||
if not data.get("password_hash") and legacy_file.exists():
|
||||
with open(legacy_file, "rb") as f:
|
||||
data["password_hash"] = f.read().decode()
|
||||
self.save_config(data)
|
||||
if require_pin and data.get("pin_hash"):
|
||||
for _ in range(3):
|
||||
pin = getpass.getpass("Enter settings PIN: ").strip()
|
||||
@@ -95,3 +107,9 @@ class ConfigManager:
|
||||
self.set_pin(new_pin)
|
||||
return True
|
||||
return False
|
||||
|
||||
def set_password_hash(self, password_hash: str) -> None:
|
||||
"""Persist the bcrypt password hash in the config."""
|
||||
config = self.load_config(require_pin=False)
|
||||
config["password_hash"] = password_hash
|
||||
self.save_config(config)
|
||||
|
Reference in New Issue
Block a user