From c4ae4561e3fb2f20bdb3f5dd559d438671b2e420 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 25 Aug 2023 14:13:22 +1000 Subject: [PATCH] main: Cleared up invalid licence response --- master/main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/master/main.py b/master/main.py index dd5037d..a4adb5e 100644 --- a/master/main.py +++ b/master/main.py @@ -43,8 +43,16 @@ def new_site(): return jsonify({'error': 'Missing domain', 'success': 'false'}) # Check if API key is a valid site key - if api_key not in open('/data/licence_key.txt', 'r').read(): - return jsonify({'error': 'Invalid API key', 'success': 'false'}) + key_file = open('/data/licence_key.txt', 'r') + valid_key = False + for line in key_file.readlines(): + if api_key == line.strip('\n'): + valid_key = True + break + key_file.close() + if not valid_key: + return jsonify({'error': 'Invalid licence', 'success': 'false'}) + # Check if domain already exists if site_exists(domain):