From ea0ba5ae303d89783bf0eaa2cf4eb55d6677b25a Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 3 Feb 2021 21:39:03 +0100 Subject: [PATCH] stages/password: use form.add_error --- authentik/stages/password/stage.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/authentik/stages/password/stage.py b/authentik/stages/password/stage.py index ee6d15b52..39c2df528 100644 --- a/authentik/stages/password/stage.py +++ b/authentik/stages/password/stage.py @@ -5,7 +5,6 @@ from django.contrib.auth import _clean_credentials from django.contrib.auth.backends import BaseBackend from django.contrib.auth.signals import user_login_failed from django.core.exceptions import PermissionDenied -from django.forms.utils import ErrorList from django.http import HttpRequest, HttpResponse from django.utils.translation import gettext as _ from django.views.generic import FormView @@ -116,8 +115,7 @@ class PasswordStageView(FormView, StageView): # No user was found -> invalid credentials LOGGER.debug("Invalid credentials") # Manually inject error into form - errors = form._errors.setdefault("password", ErrorList()) - errors.append(_("Invalid password")) + form.add_error("password", _("Invalid password")) return self.form_invalid(form) # User instance returned from authenticate() has .backend property set self.executor.plan.context[PLAN_CONTEXT_PENDING_USER] = user