Add password visibility toggle to login; auto-sync admin password from ENV

- Login.tsx: Eye/EyeOff toggle button on password field
- main.py: _seed_admin() now updates stored bcrypt hash when ENV password changed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Audiolib
2026-05-26 13:21:23 +02:00
parent c65b8ba5cf
commit adbe3c2507
2 changed files with 26 additions and 10 deletions

View File

@@ -10,7 +10,7 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler
from .database import init_db, AsyncSessionLocal
from .config import get_settings
from .models import User, Library
from .services.auth import hash_password, create_token
from .services.auth import hash_password, verify_password, create_token
from .services.file_watcher import start_file_watcher, stop_file_watcher
from .services.podcast_feed import update_all_feeds
from sqlalchemy import select
@@ -25,7 +25,12 @@ async def _seed_admin():
settings = get_settings()
async with AsyncSessionLocal() as db:
result = await db.execute(select(User).where(User.is_admin == True))
if result.scalar_one_or_none():
existing = result.scalar_one_or_none()
if existing:
if not verify_password(settings.admin_password, existing.password_hash):
existing.password_hash = hash_password(settings.admin_password)
await db.commit()
logger.info("Admin-Passwort aus ENV aktualisiert.")
return
logger.info(f"Lege Admin-User an: {settings.admin_username}")
admin = User(