UPDATE: Added stream title and selected category to users table

This commit is contained in:
2025-01-29 00:38:10 +00:00
parent 252ca7d1e6
commit bc1a48a571
5 changed files with 29 additions and 16 deletions

View File

@@ -3,6 +3,7 @@ from werkzeug.security import generate_password_hash, check_password_hash
from flask_cors import cross_origin
from database.database import Database
from blueprints.utils import login_required, sanitizer
from secrets import token_hex
auth_bp = Blueprint("auth", __name__)
@@ -78,16 +79,18 @@ def signup():
# Create new user once input is validated
cursor.execute(
"""INSERT INTO users
(username, password, email, num_followers, stream_key, is_partnered, bio)
VALUES (?, ?, ?, ?, ?, ?, ?)""",
(username, password, email, num_followers, stream_key, is_partnered, bio, current_stream_title, current_selected_category_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
(
username,
generate_password_hash(password),
email,
0,
'1',
token_hex(32),
0,
"This user does not have a Bio."
"This user does not have a Bio.",
"My Stream",
None
)
)
db.commit_data()

View File

@@ -181,11 +181,18 @@ def publish_stream():
# Check if stream key is valid
db = Database()
db.create_connection()
stream = db.fetchone("SELECT username FROM users WHERE stream_key = ?", (stream_key,))
user_info = db.fetchone("""SELECT user_id, username
FROM users
WHERE stream_key = ?""", (stream_key,))
## TODO: Add stream to database
if not stream:
if not user_info:
return "Unauthorized", 403
return redirect(f"/{stream['username']}")
return redirect(f"/{user_info['username']}")
@stream_bp.route("/end_stream", methods=["POST"])
def end_stream():
"""
Ends a stream
"""
return