Make sure the wifi password adheres to the hostapd rules
This commit is contained in:
parent
e79969805d
commit
3d83c96586
3 changed files with 9 additions and 4 deletions
|
|
@ -12,6 +12,11 @@ def hostname_check(form, field):
|
||||||
if not matches:
|
if not matches:
|
||||||
raise ValidationError(_l('Only dashes, underscores, letters and numbers allowed'))
|
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):
|
class LoginForm(FlaskForm):
|
||||||
username = StringField(_l('Username'), validators=[DataRequired()])
|
username = StringField(_l('Username'), validators=[DataRequired()])
|
||||||
|
|
@ -23,7 +28,7 @@ class LoginForm(FlaskForm):
|
||||||
class SettingsForm(FlaskForm):
|
class SettingsForm(FlaskForm):
|
||||||
# Access point settings
|
# Access point settings
|
||||||
ssid = StringField(_l('SSID'), validators=[DataRequired(), Length(1, 64), hostname_check])
|
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'))
|
enable_access_point = BooleanField(_l('Enable Access Point'))
|
||||||
# Customisation settings
|
# Customisation settings
|
||||||
butterbox_name = StringField(_l('Butterbox Name'), validators=[DataRequired()])
|
butterbox_name = StringField(_l('Butterbox Name'), validators=[DataRequired()])
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
<label class="label is-large">Services</label>
|
<label class="label is-large">Services</label>
|
||||||
|
|
||||||
<div class="field checkbox">
|
<div class="field checkbox" style="display: none">
|
||||||
{{ wtf.form_bool_field(form.enable_map_viewer) }}
|
{{ wtf.form_bool_field(form.enable_map_viewer) }}
|
||||||
<p class="help butter-form-margin">Whether map services are enabled.</p>
|
<p class="help butter-form-margin">Whether map services are enabled.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
{{ wtf.form_bool_field(form.enable_file_viewer) }}
|
{{ wtf.form_bool_field(form.enable_file_viewer) }}
|
||||||
<p class="help butter-form-margin">Whether files services via USB are enabled.</p>
|
<p class="help butter-form-margin">Whether files services via USB are enabled.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="field checkbox">
|
<div class="field checkbox" style="display: none">
|
||||||
{{ wtf.form_bool_field(form.enable_app_store) }}
|
{{ wtf.form_bool_field(form.enable_app_store) }}
|
||||||
<p class="help">Whether app store services are enabled.</p>
|
<p class="help">Whether app store services are enabled.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ def check_settings(raspap_installed: bool):
|
||||||
run(["sudo", "reboot"])
|
run(["sudo", "reboot"])
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
raspap_installed = os.path.exists("/var/www/html/raspapd")
|
raspap_installed = os.path.exists("/var/www/html/raspap")
|
||||||
while True:
|
while True:
|
||||||
print("Sleep 10 sec")
|
print("Sleep 10 sec")
|
||||||
check_settings(raspap_installed)
|
check_settings(raspap_installed)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue