mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
removed second password field from configure form and validate the form completly within clean function of configure form
This commit is contained in:
parent
5b71ce815c
commit
76f9d087c9
@ -98,11 +98,6 @@ class ConfigureForm(forms.Form):
|
|||||||
help_text=_('You should have been requested to select a password \
|
help_text=_('You should have been requested to select a password \
|
||||||
when you created the account.'))
|
when you created the account.'))
|
||||||
|
|
||||||
dynamicdns_secret_repeat = TrimmedCharField(
|
|
||||||
label=_('repeat Password'), widget=forms.PasswordInput(),
|
|
||||||
required=False,
|
|
||||||
help_text=_('insert the password again to avoid typos.'),)
|
|
||||||
|
|
||||||
dynamicdns_ipurl = TrimmedCharField(
|
dynamicdns_ipurl = TrimmedCharField(
|
||||||
label=_('IP check URL'),
|
label=_('IP check URL'),
|
||||||
required=False,
|
required=False,
|
||||||
@ -118,11 +113,10 @@ class ConfigureForm(forms.Form):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(ConfigureForm, self).clean()
|
cleaned_data = super(ConfigureForm, self).clean()
|
||||||
dynamicdns_secret = cleaned_data.get("dynamicdns_secret")
|
dynamicdns_secret = cleaned_data.get("dynamicdns_secret")
|
||||||
dynamicdns_secret_repeat = cleaned_data.get("dynamicdns_secret_repeat")
|
old_dynamicdns_secret = self.initial['dynamicdns_secret']
|
||||||
|
|
||||||
if dynamicdns_secret or dynamicdns_secret_repeat:
|
if not dynamicdns_secret and not old_dynamicdns_secret:
|
||||||
if dynamicdns_secret != dynamicdns_secret_repeat:
|
raise forms.ValidationError("please give a password")
|
||||||
raise forms.ValidationError("password missmatch")
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@ -133,7 +127,7 @@ def configure(request):
|
|||||||
form = None
|
form = None
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = ConfigureForm(request.POST, prefix='dynamicdns')
|
form = ConfigureForm(request.POST, initial=status, prefix='dynamicdns')
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
_apply_changes(request, status, form.cleaned_data)
|
_apply_changes(request, status, form.cleaned_data)
|
||||||
status = get_status()
|
status = get_status()
|
||||||
@ -213,10 +207,6 @@ def _apply_changes(request, old_status, new_status):
|
|||||||
LOGGER.info('New status is - %s', new_status)
|
LOGGER.info('New status is - %s', new_status)
|
||||||
LOGGER.info('Old status was - %s', old_status)
|
LOGGER.info('Old status was - %s', old_status)
|
||||||
|
|
||||||
if old_status['dynamicdns_secret'] == '' and \
|
|
||||||
new_status['dynamicdns_secret'] == '':
|
|
||||||
messages.error(request, _('please give a password'))
|
|
||||||
else:
|
|
||||||
if new_status['dynamicdns_secret'] == '':
|
if new_status['dynamicdns_secret'] == '':
|
||||||
new_status['dynamicdns_secret'] = old_status['dynamicdns_secret']
|
new_status['dynamicdns_secret'] = old_status['dynamicdns_secret']
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user