stages/prompt: skip password equality check when previous checks failed

This commit is contained in:
Jens Langhammer 2020-10-18 22:53:41 +02:00
parent a9ee67bf2d
commit ff64182ae8
3 changed files with 5 additions and 2 deletions

View file

@ -101,7 +101,7 @@
{
"identifiers": {
"pk": "975d5502-1e22-4d10-b560-fbc5bd70ff4d",
"name": "default-password-change-prompt"
"name": "Change your password"
},
"model": "passbook_stages_prompt.promptstage",
"attrs": {

View file

@ -27,7 +27,7 @@ def create_default_password_change(apps: Apps, schema_editor: BaseDatabaseSchema
)
prompt_stage, _ = PromptStage.objects.using(db_alias).update_or_create(
name="default-password-change-prompt",
name="Change your password",
)
password_prompt, _ = Prompt.objects.using(db_alias).update_or_create(
field_key="password",

View file

@ -113,6 +113,8 @@ class PromptForm(forms.Form):
def clean(self):
cleaned_data = super().clean()
if cleaned_data == {}:
return {}
# Check if we have two password fields, and make sure they are the same
password_fields: QuerySet[Prompt] = self.stage.fields.filter(
type=FieldTypes.PASSWORD
@ -127,6 +129,7 @@ class PromptForm(forms.Form):
result = engine.result
if not result.passing:
raise forms.ValidationError(list(result.messages))
return cleaned_data
def username_field_cleaner_factory(field: Prompt) -> Callable: