Better logging.

This commit is contained in:
2026-02-04 20:31:54 -05:00
parent 786d0bad6d
commit 16db4e7d24

View File

@@ -51,9 +51,13 @@ with app.app_context():
db.session.commit()
else:
# Ensure admin privileges and sync password with Env Var (allows password reset via Docker)
print(f"🔐 System: Syncing Admin User '{config.ADMIN_USER}' settings from environment.")
if not admin.is_admin: admin.is_admin = True
admin.password = generate_password_hash(config.ADMIN_PASSWORD, method='pbkdf2:sha256')
db.session.add(admin)
db.session.commit()
elif not User.query.filter_by(is_admin=True).first():
print(" System: No Admin credentials found in environment variables. Admin account not created.")
# Migration: Add 'progress' column if missing
try:
@@ -115,6 +119,8 @@ def login():
if not next_page or not is_safe_url(next_page):
next_page = url_for('index')
return redirect(next_page)
if user and user.is_admin:
print(f"⚠️ System: Admin login failed for '{username}'. Password hash mismatch.")
flash('Invalid credentials')
return render_template('login.html')