[Bug fix] block headers without app version

- Fix a bug that headers without `AppVersion` are allowed in client version checking.
This commit is contained in:
Lost-MSth
2023-01-22 22:09:15 +08:00
parent 9636722709
commit 88d949fc18
2 changed files with 10 additions and 12 deletions

View File

@@ -16,10 +16,10 @@ bp = Blueprint('user', __name__, url_prefix='/user')
@bp.route('', methods=['POST']) # 注册接口
@arc_try
def register():
if 'AppVersion' in request.headers: # 版本检查
if Config.ALLOW_APPVERSION:
if request.headers['AppVersion'] not in Config.ALLOW_APPVERSION:
raise NoAccess('Wrong app version.', 1203)
headers = request.headers
if Config.ALLOW_APPVERSION: # 版本检查
if 'AppVersion' not in headers or headers['AppVersion'] not in Config.ALLOW_APPVERSION:
raise NoAccess('Invalid app version.', 1203)
with Connect() as c:
new_user = UserRegister(c)