From ff64182ae874ace40983cbab95b1c3f3dee497b1 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 18 Oct 2020 22:53:41 +0200 Subject: [PATCH] stages/prompt: skip password equality check when previous checks failed --- docs/flow/examples/recovery-email-verification.json | 2 +- .../password/migrations/0002_passwordstage_change_flow.py | 2 +- passbook/stages/prompt/forms.py | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/flow/examples/recovery-email-verification.json b/docs/flow/examples/recovery-email-verification.json index f3843d1bb..e3c849263 100644 --- a/docs/flow/examples/recovery-email-verification.json +++ b/docs/flow/examples/recovery-email-verification.json @@ -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": { diff --git a/passbook/stages/password/migrations/0002_passwordstage_change_flow.py b/passbook/stages/password/migrations/0002_passwordstage_change_flow.py index 55269ce63..2d1fbb381 100644 --- a/passbook/stages/password/migrations/0002_passwordstage_change_flow.py +++ b/passbook/stages/password/migrations/0002_passwordstage_change_flow.py @@ -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", diff --git a/passbook/stages/prompt/forms.py b/passbook/stages/prompt/forms.py index 11f2a44da..598dc3c08 100644 --- a/passbook/stages/prompt/forms.py +++ b/passbook/stages/prompt/forms.py @@ -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: