Update to v2.6.6 without release

- Fix a bug about purchase discount
- Fix a bug about database synchronization, which may make 'api_login' table empty
- For Arcaea 3.8.8
- Update a logout api
This commit is contained in:
Lost-MSth
2021-10-22 20:00:22 +08:00
parent a523ff5aae
commit b494b93c14
9 changed files with 33 additions and 13 deletions

View File

@@ -52,9 +52,14 @@ def login(auth: str, ip: str):
return {'token': token, 'user_id': user_id}, 0
def logout():
# 登出接口
pass
def logout(user: User):
# 登出接口,返回错误码
code = 999
with Connect() as c:
c.execute('''delete from api_login where user_id=?''', (user.user_id,))
code = 0
return code
def id_get_role_id(c, user_id):
@@ -119,7 +124,7 @@ def role_required(request, power=[]):
return jsonify({'status': 400, 'code': -1, 'data': {}, 'msg': 'Payload must be a valid json'})
if not 'Token' in request.headers:
return jsonify({'status': 401, 'code': -1, 'data': {}, 'msg': 'No Token'})
return jsonify({'status': 401, 'code': -1, 'data': {}, 'msg': 'No token'})
user = User()
if Config.API_TOKEN == request.headers['Token'] and Config.API_TOKEN != '':
@@ -131,7 +136,7 @@ def role_required(request, power=[]):
user.user_id = api_token_get_id(
c, request.headers['Token'])
if user.user_id is None:
return jsonify({'status': 404, 'code': -1, 'data': {}, 'msg': ''})
return jsonify({'status': 401, 'code': -1, 'data': {}, 'msg': 'No token'})
role_id = id_get_role_id(c, user.user_id)
user.role = role_id_get_role(c, role_id)