UPDATE: User page allows for profile image upload if on their own profile
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from flask import Blueprint, jsonify, session
|
||||
from flask import Blueprint, jsonify, session, request
|
||||
from utils.user_utils import *
|
||||
from utils.auth import *
|
||||
from utils.utils import get_category_id
|
||||
@@ -6,6 +6,9 @@ from blueprints.middleware import login_required
|
||||
from utils.email import send_email, forgot_password_body, newsletter_conf
|
||||
import redis
|
||||
|
||||
from io import BytesIO
|
||||
from PIL import Image
|
||||
|
||||
redis_url = "redis://redis:6379/1"
|
||||
r = redis.from_url(redis_url, decode_responses=True)
|
||||
|
||||
@@ -33,6 +36,31 @@ def user_stream_key(username: str):
|
||||
data = db.fetchone("SELECT stream_key FROM users WHERE user_id = ?", (user_id,))
|
||||
return jsonify({"stream_key": data["stream_key"]})
|
||||
|
||||
@login_required
|
||||
@user_bp.route('/user/profile_picture/upload', methods=['POST'])
|
||||
def user_profile_picture_save():
|
||||
"""
|
||||
Saves user profile picture
|
||||
"""
|
||||
user_id = session.get("user_id")
|
||||
image = request.files['image']
|
||||
ext = image.filename.split('.')[-1]
|
||||
|
||||
image.save(f"/web_server/stream_data/{user_id}.{ext}")
|
||||
|
||||
return "Success", 200
|
||||
|
||||
@login_required
|
||||
@user_bp.route('/user/same/<string:username>')
|
||||
def user_is_same(username):
|
||||
"""
|
||||
Returns if given user is current user
|
||||
"""
|
||||
current_username = session.get("username")
|
||||
if username == current_username:
|
||||
return jsonify({"same": True})
|
||||
return jsonify({"same": False})
|
||||
|
||||
## Subscription Routes
|
||||
@login_required
|
||||
@user_bp.route('/user/subscription/<string:streamer_name>')
|
||||
@@ -146,7 +174,7 @@ def user_login_status():
|
||||
'username': username,
|
||||
'user_id': user_id})
|
||||
|
||||
@user_bp.route('/user/forgot_password/<string:email>', methods=['GET','POST'])
|
||||
@user_bp.route('/user/forgot_password/<string:email>', methods=['POST'])
|
||||
def user_forgot_password(email):
|
||||
"""
|
||||
Initializes the function to handle password reset
|
||||
|
||||
@@ -28,4 +28,5 @@ flask-oauthlib==0.9.6
|
||||
celery==5.2.3
|
||||
redis==5.2.1
|
||||
python-dateutil
|
||||
Authlib==1.4.1
|
||||
Authlib==1.4.1
|
||||
Pillow==11.1.0
|
||||
Reference in New Issue
Block a user