UPDATE: Added stream title and selected category to users table
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Binary file not shown.
@@ -7,12 +7,12 @@ INSERT INTO categories (category_name) VALUES
|
||||
('Sports');
|
||||
|
||||
-- Sample data for users
|
||||
INSERT INTO users (username, password, email, num_followers, stream_key, is_partnered, bio) VALUES
|
||||
('GamerDude', 'password123', 'gamerdude@example.com', 500, '1234', 0, 'Streaming my gaming adventures!'),
|
||||
('MusicLover', 'music4life', 'musiclover@example.com', 1200, '2345', 0, 'I share my favorite tunes.'),
|
||||
('ArtFan', 'artistic123', 'artfan@example.com', 300, '3456', 0, 'Exploring the world of art.'),
|
||||
('EduGuru', 'learn123', 'eduguru@example.com', 800, '4567', 0, 'Teaching everything I know.'),
|
||||
('SportsStar', 'sports123', 'sportsstar@example.com', 2000, '5678', 0, 'Join me for live sports updates!');
|
||||
INSERT INTO users (username, password, email, num_followers, stream_key, is_partnered, bio, current_stream_title, current_selected_category_id) VALUES
|
||||
('GamerDude', 'password123', 'gamerdude@example.com', 500, '1234', 0, 'Streaming my gaming adventures!', 'Epic Gaming Session', 1),
|
||||
('MusicLover', 'music4life', 'musiclover@example.com', 1200, '2345', 0, 'I share my favorite tunes.', 'Live Music Jam', 2),
|
||||
('ArtFan', 'artistic123', 'artfan@example.com', 300, '3456', 0, 'Exploring the world of art.', 'Sketching Live', 3),
|
||||
('EduGuru', 'learn123', 'eduguru@example.com', 800, '4567', 0, 'Teaching everything I know.', 'Math Made Easy', 4),
|
||||
('SportsStar', 'sports123', 'sportsstar@example.com', 2000, '5678', 0, 'Join me for live sports updates!', 'Sports Highlights', 5);
|
||||
|
||||
-- Sample data for streams
|
||||
INSERT INTO streams (user_id, title, start_time, num_viewers, isLive, vod_id, category_id) VALUES
|
||||
|
||||
@@ -11,7 +11,10 @@ CREATE TABLE users
|
||||
num_followers INTEGER NOT NULL,
|
||||
stream_key VARCHAR(60) NOT NULL,
|
||||
is_partnered BOOLEAN NOT NULL DEFAULT 0,
|
||||
bio VARCHAR(1024)
|
||||
bio VARCHAR(1024),
|
||||
|
||||
current_stream_title VARCHAR(100),
|
||||
current_selected_category_id INTEGER
|
||||
);
|
||||
|
||||
SELECT * FROM users;
|
||||
|
||||
Reference in New Issue
Block a user