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:
|
||||
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()])
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
<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) }}
|
||||
<p class="help butter-form-margin">Whether map services are enabled.</p>
|
||||
</div>
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
{{ wtf.form_bool_field(form.enable_file_viewer) }}
|
||||
<p class="help butter-form-margin">Whether files services via USB are enabled.</p>
|
||||
</div>
|
||||
<div class="field checkbox">
|
||||
<div class="field checkbox" style="display: none">
|
||||
{{ wtf.form_bool_field(form.enable_app_store) }}
|
||||
<p class="help">Whether app store services are enabled.</p>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue