[FIX] Fix bug in api/user.py

This commit is contained in:
jinyx 2023-03-31 16:47:39 +08:00
parent ad4da46cef
commit ddef9a876c
1 changed files with 9 additions and 9 deletions

View File

@ -14,6 +14,15 @@ def index():
return f"User API Index {C.stats}"
@user_api.before_app_request
def load_logged_in_user():
user_id = session.get('user_id')
if user_id is None:
g.user = None
else:
g.user = get_user_info(by='id', value=user_id)
@user_api.route('/register', methods=['POST'])
def register():
if request.method == 'POST':
@ -59,15 +68,6 @@ def login():
return jsonify(result)
@user_api.before_app_request
def load_logged_in_user():
user_id = session.get('user_id')
if user_id is None:
g.user = None
else:
g.user = get_user_info(by='id', value=user_id)
@user_api.route('/logout', methods=['POST'])
def logout():
if g.user is None: