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):
|
def form_invalid(self, form):
|
||||||
# forms.non_field_errors() returns strings for some reason
|
# forms.non_field_errors() returns strings for some reason
|
||||||
non_field_errors = form.errors["__all__"].as_data()
|
non_field_errors = form.errors["__all__"].as_data()
|
||||||
exte_login_error = next(
|
for e in non_field_errors:
|
||||||
(e for e in non_field_errors if e.code in ["has_clipper", "no_password"]),
|
if e.code in ["has_clipper", "no_password"]:
|
||||||
None,
|
return render(self.request, "login_error.html", {"error_code": e.code})
|
||||||
)
|
|
||||||
|
|
||||||
if exte_login_error is not None:
|
|
||||||
return render(
|
|
||||||
self.request, "login_error.html", {"error_code": exte_login_error.code}
|
|
||||||
)
|
|
||||||
return super().form_invalid(form)
|
return super().form_invalid(form)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue