Implement license validation endpoint and update templates; add test script
This commit is contained in:
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
.venv
|
.venv
|
||||||
__pycache__
|
__pycache__
|
||||||
build
|
build
|
||||||
|
main.dist
|
||||||
+11
-7
@@ -1,9 +1,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template, request, jsonify
|
||||||
import verify
|
import verify
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
|
|
||||||
def _resolve_template_dir() -> Path:
|
def _resolve_template_dir() -> Path:
|
||||||
candidates = [
|
candidates = [
|
||||||
@@ -38,9 +36,9 @@ def _read_app_version() -> str:
|
|||||||
|
|
||||||
APP_VERSION = _read_app_version()
|
APP_VERSION = _read_app_version()
|
||||||
|
|
||||||
@app.route("/_validate__information", methods=['POST'])
|
@app.route("/validate__information", methods=['POST'])
|
||||||
def default():
|
def validate__information():
|
||||||
data = requests.get_json()
|
data = request.get_json(silent=True)
|
||||||
if not data:
|
if not data:
|
||||||
return jsonify({"error": "No JSON data provided"}), 400
|
return jsonify({"error": "No JSON data provided"}), 400
|
||||||
license_key = data.get("license")
|
license_key = data.get("license")
|
||||||
@@ -48,7 +46,13 @@ def default():
|
|||||||
if not license_key or not hwid_uuid:
|
if not license_key or not hwid_uuid:
|
||||||
return jsonify({"error": "Missing 'license' or 'hwid' in JSON data"}), 400
|
return jsonify({"error": "Missing 'license' or 'hwid' in JSON data"}), 400
|
||||||
if verify.check(license_key, hwid_uuid):
|
if verify.check(license_key, hwid_uuid):
|
||||||
return 200
|
return jsonify({"status": "ok"}), 200
|
||||||
|
else:
|
||||||
|
return jsonify({"status": "invalid"}), 402
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def default():
|
||||||
|
return render_template("main.html")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@@ -1,4 +1,2 @@
|
|||||||
<a>This is a Test If this works it would be great!</a>
|
<a>This is a Test If this works it would be great!</a>
|
||||||
<p>Version: {{ version }}</p>
|
<p>Version: {{ version }}</p>
|
||||||
<p>UUID: {{ uuid }}</p>
|
|
||||||
<p>License Key: {{ license }}</p>
|
|
||||||
+1
-1
@@ -2,7 +2,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
import secrets
|
import secrets
|
||||||
|
|
||||||
LICENSES_FILE = os.path.abspath(os.path.join(os.path.dirname(__file__), "licenses.json"))
|
LICENSES_FILE = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "licenses.json"))
|
||||||
|
|
||||||
|
|
||||||
def load_file() -> dict:
|
def load_file() -> dict:
|
||||||
|
|||||||
+2
-2
@@ -31,7 +31,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user_id": "0007",
|
"user_id": "0007",
|
||||||
"license_key": "OW-vmNd7P_Xyije4Nv7fcytwkawcUOUDrbWR3YFYYlU",
|
"license_key": "TEST-KEY-123",
|
||||||
"hwid_uuid": ""
|
"hwid_uuid": "HWID-ABC-999"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user