Cleaner error code management
This commit is contained in:
parent
5f963d5451
commit
2c49b25d59
1 changed files with 3 additions and 9 deletions
|
@ -89,15 +89,9 @@ class LoginExtView(DjangoLoginView):
|
|||
def form_invalid(self, form):
|
||||
# forms.non_field_errors() returns strings for some reason
|
||||
non_field_errors = form.errors["__all__"].as_data()
|
||||
exte_login_error = next(
|
||||
(e for e in non_field_errors if e.code in ["has_clipper", "no_password"]),
|
||||
None,
|
||||
)
|
||||
|
||||
if exte_login_error is not None:
|
||||
return render(
|
||||
self.request, "login_error.html", {"error_code": exte_login_error.code}
|
||||
)
|
||||
for e in non_field_errors:
|
||||
if e.code in ["has_clipper", "no_password"]:
|
||||
return render(self.request, "login_error.html", {"error_code": e.code})
|
||||
return super().form_invalid(form)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue