FastAPI-Backend und React-Frontend mit Konten, Sendungsverfolgung, Projekt-Artikeln, Vorrat & Einkauf mit Rezeptabgleich, Reise-Weltkarte, Kanban-Projekten mit Priorität, Server-Monitoring und den Designs Matrix und Blackwall. Betrieb per Docker hinter nginx (siehe DEPLOY.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
"""Notfall: Passwort eines Kontos neu setzen (z. B. wenn der einzige Admin es vergessen hat).
|
|
|
|
Aufruf im Ordner backend/: .venv/bin/python -m app.reset_password BENUTZERNAME
|
|
"""
|
|
import getpass
|
|
import sys
|
|
|
|
from .auth import MIN_PASSWORD, hash_password
|
|
from .db import transaction
|
|
|
|
|
|
def main() -> None:
|
|
if len(sys.argv) != 2:
|
|
sys.exit("Aufruf: python -m app.reset_password BENUTZERNAME")
|
|
username = sys.argv[1]
|
|
password = getpass.getpass(f"Neues Passwort für {username}: ")
|
|
if len(password) < MIN_PASSWORD:
|
|
sys.exit(f"Das Passwort muss mindestens {MIN_PASSWORD} Zeichen lang sein.")
|
|
if getpass.getpass("Wiederholen: ") != password:
|
|
sys.exit("Die Passwörter stimmen nicht überein.")
|
|
with transaction() as conn:
|
|
cur = conn.execute("UPDATE users SET password_hash = ? WHERE username = ?", (hash_password(password), username))
|
|
if not cur.rowcount:
|
|
sys.exit(f"Kein Konto mit dem Benutzernamen „{username}“.")
|
|
conn.execute("DELETE FROM sessions WHERE user_id = (SELECT id FROM users WHERE username = ?)", (username,))
|
|
print("Passwort geändert.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|