Admin Dashboard, Hilfe-Seite, Dockerfile Fixes (gunicorn, UID 1000, HOME)
This commit is contained in:
@@ -7,8 +7,9 @@ RUN pip install --no-cache-dir -r requirements.txt gunicorn
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN addgroup --system app && adduser --system --ingroup app --home /app app && \
|
||||
chown -R app:app /app
|
||||
RUN addgroup --system --gid 1000 app && adduser --system --uid 1000 --ingroup app app && \
|
||||
chown -R app:app /app && chmod -R u+w /app
|
||||
ENV HOME=/app
|
||||
USER app
|
||||
|
||||
EXPOSE 5005
|
||||
|
||||
21
app.py
21
app.py
@@ -54,11 +54,14 @@ login_manager.login_view = "login" # Nicht eingeloggte User werden zum Login um
|
||||
# Config-Helfer
|
||||
# -------------------------------------------------
|
||||
def load_config():
|
||||
"""Liest die config.json und gibt das Dict zurück. Legt ein leeres an, falls nicht vorhanden."""
|
||||
"""Liest die config.json und gibt das Dict zurück. Legt ein leeres an, falls nicht vorhanden oder fehlerhaft."""
|
||||
if not os.path.exists(CONFIG_FILE):
|
||||
return {"admin": {}, "sites": {}}
|
||||
try:
|
||||
with open(CONFIG_FILE) as f:
|
||||
return json.load(f)
|
||||
except (json.JSONDecodeError, OSError):
|
||||
return {"admin": {}, "sites": {}}
|
||||
|
||||
|
||||
def save_config(cfg):
|
||||
@@ -295,11 +298,14 @@ class User(UserMixin):
|
||||
|
||||
|
||||
def load_users():
|
||||
"""Liest die users.json. Gibt leeres Dict zurück, wenn nicht vorhanden."""
|
||||
"""Liest die users.json. Gibt leeres Dict zurück, wenn nicht vorhanden oder fehlerhaft."""
|
||||
if not os.path.exists(USERS_FILE):
|
||||
return {}
|
||||
try:
|
||||
with open(USERS_FILE) as f:
|
||||
return json.load(f)
|
||||
except (json.JSONDecodeError, OSError):
|
||||
return {}
|
||||
|
||||
|
||||
def save_users(users):
|
||||
@@ -318,9 +324,15 @@ def get_user(email):
|
||||
|
||||
|
||||
def init_user_db():
|
||||
"""Legt users.json mit einem Admin-Konto aus config.json.admin an, falls sie nicht existiert."""
|
||||
"""Legt users.json mit einem Admin-Konto aus config.json.admin an, falls sie nicht existiert oder leer ist."""
|
||||
if os.path.exists(USERS_FILE):
|
||||
try:
|
||||
with open(USERS_FILE) as f:
|
||||
content = f.read().strip()
|
||||
if content:
|
||||
return
|
||||
except OSError:
|
||||
pass
|
||||
cfg = load_config()
|
||||
admin = cfg.get("admin", {})
|
||||
username = admin.get("username", "admin@signage.local")
|
||||
@@ -1584,7 +1596,10 @@ def admin_users_reset_password(email):
|
||||
# -------------------------------------------------
|
||||
# Main
|
||||
# -------------------------------------------------
|
||||
try:
|
||||
init_user_db()
|
||||
except Exception as e:
|
||||
print(f"⚠️ init_user_db fehlgeschlagen: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True, host="0.0.0.0", port=5005)
|
||||
|
||||
Reference in New Issue
Block a user