MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / discussion_file_stream

Function discussion_file_stream

Scripts/ButSystem.py:13020–13060  ·  view source on GitHub ↗

Inline media stream for Discussion attachments.

(fid: int)

Source from the content-addressed store, hash-verified

13018 return redirect(url_for("admin_panel"))
13019 # Do not promote self redundantly
13020 conn = db_connect()
13021 row = conn.execute("SELECT is_admin FROM users WHERE username=?", (u,)).fetchone()
13022 if not row:
13023 conn.close()
13024 flash("User not found.")
13025 return redirect(url_for("admin_panel"))
13026 if int(row["is_admin"]) == 1:
13027 conn.close()
13028 flash("User is already an admin.")
13029 return redirect(url_for("admin_panel"))
13030
13031 # Promote + bind to this device (admin actions are allowed only locally on the host device)
13032 conn.execute("UPDATE users SET is_admin=1, admin_device_id=? WHERE username=?", (DEVICE_ID, u))
13033 conn.commit()
13034 conn.close()
13035 flash(f"Promoted @{u} to admin.")
13036 return redirect(url_for("admin_panel"))
13037
13038@app.route("/admin/demote", methods=["POST"])
13039@login_required
13040def admin_demote():
13041 """admin_demote.
13042
13043Admin-only route handler.
13044
13045This docstring was expanded to make future maintenance easier.
13046
13047Returns:
13048 Varies.
13049"""
13050 require_admin()
13051 try:
13052 log_security_event("admin_action", detail="demote_user", username=current_user(), level="info")
13053 except Exception:
13054 pass
13055 u = (request.form.get("username") or "").strip()
13056 if not u:
13057 return redirect(url_for("admin_panel"))
13058 if u == current_user():
13059 flash("You cannot demote yourself here.")
13060 return redirect(url_for("admin_panel"))
13061
13062 conn = db_connect()
13063 # Ensure we don't remove the last admin

Callers

nothing calls this directly

Calls 7

_feature_tables_initFunction · 0.70
current_userFunction · 0.70
db_connectFunction · 0.70
guess_mimeFunction · 0.70
is_inline_safeFunction · 0.70
is_encrypted_fileFunction · 0.70
aesgcm_decrypt_generatorFunction · 0.70

Tested by

no test coverage detected