From 7f0826c77419160bdf0d2a660eebbbcd4cdb8744 Mon Sep 17 00:00:00 2001 From: Thomas Rusiecki Date: Thu, 28 Nov 2024 02:13:09 -0300 Subject: [PATCH] login error message on incorrect credentials --- login/views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/login/views.py b/login/views.py index beb0368..17ebbe2 100644 --- a/login/views.py +++ b/login/views.py @@ -1,5 +1,6 @@ import logging +from django.contrib import messages from django.conf import settings from django.urls import reverse_lazy from django.contrib.auth import views as auth_views @@ -39,6 +40,10 @@ class LoginView(auth_views.LoginView): return redirect(reverse_lazy("login:login")) return redirect(self.extra_context['success_url']) + + def form_invalid(self, form): + messages.error(self.request, _("Login error. Check credentials.")) + return self.render_to_response(self.get_context_data(form=form), status=401) def LogoutView(request):