FEAT: Users can now edit their own user bios

This commit is contained in:
JustIceO7
2025-03-05 02:54:50 +00:00
parent dd0a557612
commit 633776dfe9
3 changed files with 94 additions and 7 deletions

View File

@@ -61,6 +61,22 @@ def user_profile_picture_save():
return jsonify({"message": "Profile picture saved", "path": thumbnail_path})
@login_required
@user_bp.route('/user/bio/change', methods=['POST'])
def user_change_bio():
"""
Changes users bio
"""
user_id = session.get("user_id")
try:
data = request.get_json()
bio = data.get("bio")
update_bio(user_id, bio)
return jsonify({"status": "Success"}), 200
except Exception as e:
return jsonify({"error": str(e)}), 400
## Subscription Routes
@login_required
@user_bp.route('/user/subscription/<string:streamer_name>')

View File

@@ -27,6 +27,17 @@ def get_username(user_id: str) -> Optional[str]:
""", (user_id,))
return data['username'] if data else None
def update_bio(user_id: int, bio: str):
"""
Updates users bio given their user_id
"""
with Database() as db:
db.execute("""
UPDATE users
SET bio = ?
WHERE user_id = ?
""", (bio, user_id))
def get_session_info_email(email: str) -> dict:
"""
Returns username and user_id given email