diff --git a/app/forms.py b/app/forms.py index 1de53bb..ebb878e 100644 --- a/app/forms.py +++ b/app/forms.py @@ -15,7 +15,7 @@ def hostname_check(form, field): def wifi_length_check(form, field): if len(field.data) > 63: raise ValidationError(_l('Wifi password cannot be longer than 63 characters.')) - if len(field.data) in range(1,8): + if len(field.data) in range(1,9): raise ValidationError(_l('Wifi password cannot be shorter than 8 characters.')) class LoginForm(FlaskForm): diff --git a/app/routes.py b/app/routes.py index f7cdf9f..097d603 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,6 +1,3 @@ -import io -import re - from app import app from flask import render_template, flash, redirect, url_for, send_file from app.forms import LoginForm, SettingsForm, Step1Form, Step2Form, Step3Form, Step4Form @@ -28,10 +25,7 @@ RASPAP_INSTALLED = os.path.exists("/var/www/html/raspap") def gen_username() -> str: words = top_n_list("en", 5000) prefix = random.randint(1000, 9999) - word1 = re.sub(r'[^a-zA-Z ]', '', random.choice(words)) - word2 = re.sub(r'[^a-zA-Z ]', '', random.choice(words)) - print(word1, word2) - return f"{word1}{word2}{prefix}" + return f"{random.choice(words)}{random.choice(words)}{prefix}" def gen_password() -> str: characters = string.ascii_letters + string.digits @@ -352,17 +346,15 @@ def messaging(): return render_template('messaging.html', get_setting=get_setting) @app.route("/deltachat_credentials", methods=["POST"]) -def deltachat_credentials(): +def generate_random_deltachat_credentials(): ip = app.config['BUTTERBOX_DEFAULT_IP'] username = gen_username() password = gen_password() - hostname = f"{get_setting('butterbox_hostname')}.local" - dclink = f"dclogin:{username}@{hostname}/?p={password}&v=1&ih={ip}&ip=143&sh={ip}&sp=25&is=plain&ss=plain&sc=3" - img = qrcode.make(dclink) - file_object = io.BytesIO() - img.save(file_object, 'PNG') - base64img = "data:image/png;base64," + base64.b64encode(file_object.getvalue()).decode('ascii') - return render_template('deltachat_creds.html',dclink=dclink, base64img=base64img, get_setting=get_setting) + + flash(f"Username: {username}") + flash(f"Password: {password}") + flash(f"IP: {ip}") + return redirect(url_for("messaging")) @app.route('/share') def share(): diff --git a/app/templates/deltachat_creds.html b/app/templates/deltachat_creds.html deleted file mode 100644 index afa9f25..0000000 --- a/app/templates/deltachat_creds.html +++ /dev/null @@ -1,24 +0,0 @@ -{% extends "base.html" %} - -{% block content %} -
{{ _('Scan the following QR code with a device where DeltaChat is installed:') }}
-{{ _('If your device does not have a camera, select "Create new profile" in DeltaChat, choose "Use Other Server" and find "Paste from clipboard", to paste the following link') }}:
{{ dclink}}
-{{ _("To use secure messaging, install Delta Chat and then create your local offline account.")}}
+{{ _("To use secure messaging, install Delta Chat and then return to this page to create your local offline account.")}}