From 18d851948247959581a3ce594c86cb7689c69cfb Mon Sep 17 00:00:00 2001 From: ThisBirchWood Date: Sun, 2 Mar 2025 16:28:11 +0000 Subject: [PATCH] UPDATE: Adjusted underlying file system to use user-centric instead of type-centric formatting --- web_server/blueprints/authentication.py | 6 ++++++ web_server/blueprints/streams.py | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/web_server/blueprints/authentication.py b/web_server/blueprints/authentication.py index 1f5cd21..45f9313 100644 --- a/web_server/blueprints/authentication.py +++ b/web_server/blueprints/authentication.py @@ -7,9 +7,12 @@ from utils.email import send_email from utils.user_utils import get_user_id from utils.utils import sanitize from secrets import token_hex +from utils.path_manager import PathManager auth_bp = Blueprint("auth", __name__) +path_manager = PathManager() + @auth_bp.route("/signup", methods=["POST"]) @cross_origin(supports_credentials=True) def signup(): @@ -90,6 +93,9 @@ def signup(): ) ) + # Create user directories for stream data + path_manager.create_user(username) + # Create session for new user, to avoid them having unnecessary state info session.clear() session["username"] = username diff --git a/web_server/blueprints/streams.py b/web_server/blueprints/streams.py index 9152c5c..4b634d5 100644 --- a/web_server/blueprints/streams.py +++ b/web_server/blueprints/streams.py @@ -203,15 +203,17 @@ def init_stream(): FROM users WHERE stream_key = ?""", (stream_key,)) + # No user found from stream key if not user_info: print("Unauthorized - Invalid stream key", flush=True) return "Unauthorized - Invalid stream key", 403 - # Create necessary directories username = user_info["username"] - create_user_directories(username) - return redirect(f"/stream/{username}") + # FOR TESTING + path_manager.create_user(username) + + return redirect(username + "/" + path_manager.stream_directory_name) @stream_bp.route("/publish_stream", methods=["POST"])