feat: Add iOS-specific enhancements and mobile compatibility utilities

- Implemented `remove_key` function in verify.py to allow key removal by user ID.
- Updated run.sh to include additional dependencies for QR code and TOTP support.
- Introduced ios_fixes.js for iOS-specific enhancements including file input handling, form submission fixes, and image handling optimizations.
- Added mobile_compatibility.js for mobile device detection and utility functions to improve compatibility, especially for iOS.
- Created base.html template for consistent layout and styling across the application.
- Developed login.html template with a password toggle feature for better user experience.
This commit is contained in:
Maximilian G.
2026-03-22 17:28:28 +00:00
committed by GitHub
parent 91feb7d010
commit f1cdfba603
8 changed files with 1088 additions and 7 deletions
+74 -3
View File
@@ -1,7 +1,9 @@
from pathlib import Path
import sys
from flask import Flask, render_template, request, jsonify
from flask import Flask, render_template, request, jsonify, flash, redirect, url_for, get_flashed_messages, session
import verify
import pyotp
import qrcode
def _resolve_template_dir() -> Path:
candidates = [
@@ -16,9 +18,10 @@ def _resolve_template_dir() -> Path:
return candidates[0]
totp_key = "Hsdfisdf4n34234dfiseLoasjfj3asnnvhxbbfgrzzuewwndcodrweokyn"
app = Flask(__name__, template_folder=str(_resolve_template_dir()))
app.secret_key = "Test123"
def _read_app_version() -> str:
candidates = [
@@ -33,6 +36,13 @@ def _read_app_version() -> str:
return "unknown"
def generate_totp_qrcode():
uri = pyotp.totp.TOTP(totp_key).provisioning_uri(name='',issuer_name='Key Verification Server')
qrcode.make(uri).save("qr.png")
def check_totp(key):
totp = pyotp.TOTP(totp_key)
return totp.verify(key)
APP_VERSION = _read_app_version()
@@ -50,9 +60,70 @@ def validate__information():
else:
return jsonify({"status": "invalid"}), 402
@app.route('/login', methods=['GET', 'POST'])
def login():
"""
User login route.
Authenticates users and redirects to appropriate homepage based on role.
Returns:
flask.Response: Rendered template or redirect
"""
if 'username' in session:
return redirect(url_for('default'))
if request.method == 'POST':
totp = request.form['password']
if not totp:
flash('Please fill all fields', 'error')
return redirect(url_for('login'))
user_log = check_totp(totp)
if user_log:
session['username'] = "Whatareyoulookingfor"
return redirect(url_for('default'))
else:
flash('Invalid credentials', 'error')
get_flashed_messages()
return render_template('login.html')
@app.route("/")
def default():
return render_template("main.html")
if 'username' not in session:
return redirect(url_for('login'))
keys = verify.load_file()
return render_template("main.html", keys=keys)
@app.route("/generate_new", methods=["POST"])
def generate_new():
if 'username' not in session:
return redirect(url_for('login'))
new_license = verify.new_key()
flash(f"New key generated: {new_license}", "success")
return redirect(url_for('default'))
@app.route("/remove_key/<user_id>", methods=["POST"])
def remove_key(user_id):
if 'username' not in session:
return redirect(url_for('login'))
if verify.remove_key(user_id):
flash(f"Key for user {user_id} removed", "success")
else:
flash(f"No key found for user {user_id}", "error")
return redirect(url_for('default'))
@app.route('/logout')
def logout():
session.pop('username', None)
flash('Logged out successfully', 'info')
return redirect(url_for('login'))
def main():