admin_promote. Admin-only route handler. This docstring was expanded to make future maintenance easier. Returns: Varies.
()
| 12129 | flash("Remove failed.") |
| 12130 | return redirect(url_for("profile")) |
| 12131 | |
| 12132 | @app.route("/profile/pic/<username>") |
| 12133 | @login_required |
| 12134 | def profile_pic(username: str): |
| 12135 | """Serve a user's profile picture. |
| 12136 | |
| 12137 | New uploads are stored plaintext. If an older encrypted blob exists, we |
| 12138 | decrypt it on the fly for backwards compatibility. |
| 12139 | """ |
| 12140 | ensure_profile_row(username) |
| 12141 | conn = db_connect() |
| 12142 | row = conn.execute("SELECT pic_path, pic_mime FROM profiles WHERE username=?", (username,)).fetchone() |
| 12143 | conn.close() |
| 12144 | if not row or not row["pic_path"] or not os.path.exists(row["pic_path"]): |
| 12145 | abort(404) |
| 12146 | |
| 12147 | mime = row["pic_mime"] or "image/jpeg" |
| 12148 | sp = row["pic_path"] |
| 12149 | |
| 12150 | try: |
| 12151 | if is_encrypted_file(sp): |
| 12152 | gen = aesgcm_decrypt_generator(sp) |
| 12153 | resp = Response(gen, mimetype=mime) |
| 12154 | else: |
| 12155 | from flask import send_file |
| 12156 | resp = send_file(sp, mimetype=mime, as_attachment=False, conditional=True, max_age=0) |
| 12157 | except Exception: |
| 12158 | abort(404) |
| 12159 | |
| 12160 | resp.headers["Cache-Control"] = "no-store" |
| 12161 | return resp |
| 12162 | |
| 12163 | |
| 12164 | # --------------------------- |
| 12165 | # Files (advanced private per-user vault; stored plaintext) |
| 12166 | # --------------------------- |
| 12167 | |
| 12168 | FILE_CATEGORIES = ( |
| 12169 | ("all", "All"), ("folders", "Folders"), ("documents", "Documents"), |
nothing calls this directly
no test coverage detected