From 3d83c96586809812264450220ec3618f152ffe0c Mon Sep 17 00:00:00 2001 From: Ana Custura Date: Thu, 12 Mar 2026 10:55:02 +0000 Subject: [PATCH] Make sure the wifi password adheres to the hostapd rules --- app/forms.py | 7 ++++++- app/templates/admin.html | 4 ++-- change_manager.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/forms.py b/app/forms.py index d8845ca..0b8dd12 100644 --- a/app/forms.py +++ b/app/forms.py @@ -12,6 +12,11 @@ def hostname_check(form, field): if not matches: raise ValidationError(_l('Only dashes, underscores, letters and numbers allowed')) +def wifi_length_check(form, field): + if len(field.data) > 63: + raise ValidationError('Wifi password cannot be longer than 63 characters.') + if len(field.data) in range(1,9): + raise ValidationError('Wifi password cannot be shorter than 8 characters.') class LoginForm(FlaskForm): username = StringField(_l('Username'), validators=[DataRequired()]) @@ -23,7 +28,7 @@ class LoginForm(FlaskForm): class SettingsForm(FlaskForm): # Access point settings ssid = StringField(_l('SSID'), validators=[DataRequired(), Length(1, 64), hostname_check]) - wifi_password = StringField(_l('WiFi Password'), validators=[Length(0, 64)]) + wifi_password = StringField(_l('WiFi Password'), validators=[wifi_length_check]) enable_access_point = BooleanField(_l('Enable Access Point')) # Customisation settings butterbox_name = StringField(_l('Butterbox Name'), validators=[DataRequired()]) diff --git a/app/templates/admin.html b/app/templates/admin.html index 79f43c3..4c466cc 100644 --- a/app/templates/admin.html +++ b/app/templates/admin.html @@ -20,7 +20,7 @@ -
+ @@ -36,7 +36,7 @@ {{ wtf.form_bool_field(form.enable_file_viewer) }}

Whether files services via USB are enabled.

-
+ diff --git a/change_manager.py b/change_manager.py index c7041f6..14f0d4b 100644 --- a/change_manager.py +++ b/change_manager.py @@ -219,7 +219,7 @@ def check_settings(raspap_installed: bool): run(["sudo", "reboot"]) if __name__ == "__main__": - raspap_installed = os.path.exists("/var/www/html/raspapd") + raspap_installed = os.path.exists("/var/www/html/raspap") while True: print("Sleep 10 sec") check_settings(raspap_installed)