fix:解决创建账号失败,但前台返回创建成功的问题,创建账号时返回真实的状态 (#57)

Co-authored-by: zqgame <zqgame@zqgame.local>
This commit is contained in:
helojo 2025-04-28 10:32:13 +08:00 committed by GitHub
parent f4d14f0099
commit e94697ec68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 5 deletions

View File

@ -45,11 +45,23 @@ def create_user_route():
"""创建用户的API端点"""
data = request.json
# 创建用户
create_user(user_data=data)
return jsonify({
"code": 0,
"message": "用户创建成功"
})
try:
success = create_user(user_data=data)
if success:
return jsonify({
"code": 0,
"message": "用户创建成功"
})
else:
return jsonify({
"code": 400,
"message": "用户创建失败"
}), 400
except Exception as e:
return jsonify({
"code": 500,
"message": f"用户创建失败: {str(e)}"
}), 500
@users_bp.route('/<string:user_id>', methods=['PUT'])
def update_user_route(user_id):