mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 15:28:44 +00:00
cli: avoid fingerprint prompt when option provided
This commit is contained in:
@@ -102,8 +102,14 @@ class PasswordManager:
|
|||||||
verification, ensuring the integrity and confidentiality of the stored password database.
|
verification, ensuring the integrity and confidentiality of the stored password database.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self, fingerprint: Optional[str] = None) -> None:
|
||||||
"""Initialize the PasswordManager."""
|
"""Initialize the PasswordManager.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
fingerprint:
|
||||||
|
Optional seed profile fingerprint to select without prompting.
|
||||||
|
"""
|
||||||
initialize_app()
|
initialize_app()
|
||||||
self.ensure_script_checksum()
|
self.ensure_script_checksum()
|
||||||
self.encryption_mode: EncryptionMode = EncryptionMode.SEED_ONLY
|
self.encryption_mode: EncryptionMode = EncryptionMode.SEED_ONLY
|
||||||
@@ -131,11 +137,16 @@ class PasswordManager:
|
|||||||
# Initialize the fingerprint manager first
|
# Initialize the fingerprint manager first
|
||||||
self.initialize_fingerprint_manager()
|
self.initialize_fingerprint_manager()
|
||||||
|
|
||||||
# Ensure a parent seed is set up before accessing the fingerprint directory
|
if fingerprint:
|
||||||
self.setup_parent_seed()
|
# Load the specified profile without prompting
|
||||||
|
self.select_fingerprint(fingerprint)
|
||||||
# Set the current fingerprint directory
|
else:
|
||||||
self.fingerprint_dir = self.fingerprint_manager.get_current_fingerprint_dir()
|
# Ensure a parent seed is set up before accessing the fingerprint directory
|
||||||
|
self.setup_parent_seed()
|
||||||
|
# Set the current fingerprint directory after selection
|
||||||
|
self.fingerprint_dir = (
|
||||||
|
self.fingerprint_manager.get_current_fingerprint_dir()
|
||||||
|
)
|
||||||
|
|
||||||
def ensure_script_checksum(self) -> None:
|
def ensure_script_checksum(self) -> None:
|
||||||
"""Initialize or verify the checksum of the manager script."""
|
"""Initialize or verify the checksum of the manager script."""
|
||||||
|
@@ -51,9 +51,10 @@ def start_server(fingerprint: str | None = None) -> str:
|
|||||||
Optional seed profile fingerprint to select before starting the server.
|
Optional seed profile fingerprint to select before starting the server.
|
||||||
"""
|
"""
|
||||||
global _pm, _token
|
global _pm, _token
|
||||||
_pm = PasswordManager()
|
if fingerprint is None:
|
||||||
if fingerprint:
|
_pm = PasswordManager()
|
||||||
_pm.select_fingerprint(fingerprint)
|
else:
|
||||||
|
_pm = PasswordManager(fingerprint=fingerprint)
|
||||||
_token = secrets.token_urlsafe(16)
|
_token = secrets.token_urlsafe(16)
|
||||||
print(f"API token: {_token}")
|
print(f"API token: {_token}")
|
||||||
origins = [
|
origins = [
|
||||||
|
@@ -44,11 +44,11 @@ app.add_typer(api_app, name="api")
|
|||||||
|
|
||||||
def _get_pm(ctx: typer.Context) -> PasswordManager:
|
def _get_pm(ctx: typer.Context) -> PasswordManager:
|
||||||
"""Return a PasswordManager optionally selecting a fingerprint."""
|
"""Return a PasswordManager optionally selecting a fingerprint."""
|
||||||
pm = PasswordManager()
|
|
||||||
fp = ctx.obj.get("fingerprint")
|
fp = ctx.obj.get("fingerprint")
|
||||||
if fp:
|
if fp is None:
|
||||||
# `select_fingerprint` will initialize managers
|
pm = PasswordManager()
|
||||||
pm.select_fingerprint(fp)
|
else:
|
||||||
|
pm = PasswordManager(fingerprint=fp)
|
||||||
return pm
|
return pm
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user