PATCH: Fixed a load of broken user routes

This commit is contained in:
2025-02-06 17:25:25 +00:00
parent 00d627a1e2
commit c0ddca85ba
5 changed files with 33 additions and 26 deletions

View File

@@ -52,23 +52,28 @@ def user_following(user_id: int, followed_id: int):
@login_required
@user_bp.route('/user/follow/<string:username>')
def follow(username):
def follow_user(username):
"""
Follows a user
"""
user_id = session.get("user_id")
following_id = get_user_id(username)
follow(user_id, following_id)
if follow(user_id, following_id):
return jsonify({"success": True,
"already_following": False})
return jsonify({"success": True,
"already_following": True})
@login_required
@user_bp.route('/user/unfollow/<string:username>')
def user_unfollow(followed_username):
def unfollow_user(username):
"""
Unfollows a user
"""
user_id = session.get("user_id")
followed_id = get_user_id(followed_username)
followed_id = get_user_id(username)
unfollow(user_id, followed_id)
return jsonify({"success": True})
@login_required
@user_bp.route('/user/following')
@@ -88,7 +93,10 @@ def get_login_status():
Returns whether the user is logged in or not
"""
username = session.get("username")
return jsonify({'status': username is not None, 'username': username})
user_id = session.get("user_id")
return jsonify({'status': username is not None,
'username': username,
'user_id': user_id})
@user_bp.route('/user/forgot_password/<string:email>', methods=['GET','POST'])
def user_forgot_password(email):