diff --git a/modoboa/core/management/commands/load_initial_data.py b/modoboa/core/management/commands/load_initial_data.py index c9f886902..2881ff614 100644 --- a/modoboa/core/management/commands/load_initial_data.py +++ b/modoboa/core/management/commands/load_initial_data.py @@ -98,7 +98,7 @@ class Command(BaseCommand): allowed_host = input("What will be the hostname used to access Modoboa? ") if not allowed_host: allowed_host = "localhost" - frontend_application = app_model.objects.filter(name="frontend") + frontend_application = app_model.objects.filter(name="Modoboa frontend") frontend_path = getattr(settings, "NEW_ADMIN_URL", "new-admin") redirect_uri = f"https://{allowed_host}/{frontend_path}/login/logged" client_id = "" diff --git a/modoboa/core/tests/test_authentication.py b/modoboa/core/tests/test_authentication.py index f1897a491..ab689472f 100644 --- a/modoboa/core/tests/test_authentication.py +++ b/modoboa/core/tests/test_authentication.py @@ -57,9 +57,6 @@ class AuthenticationTestCase(ModoTestCase): user.save() data = {"username": "user@test.com", "password": "toto"} response = self.client.post(reverse("core:login"), data) - - response = self.client.get(response.url) - self.assertEqual(response.status_code, 302) url = reverse("core:2fa_verify") self.assertTrue(response.url.endswith(url)) diff --git a/modoboa/core/views/auth.py b/modoboa/core/views/auth.py index 881001119..9b6fb0198 100644 --- a/modoboa/core/views/auth.py +++ b/modoboa/core/views/auth.py @@ -76,11 +76,13 @@ class LoginView(LoginViewMixin, auth_views.LoginView): template_name = "registration/login.html" def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) announcements = signals.get_announcements.send( sender="login", location="loginpage" ) announcements = [announcement[1] for announcement in announcements] - return super().get_context_data(announcements=announcements, **kwargs) + context.update({"announcements": announcements}) + return context def check_password_hash(self, user, form): condition = user.is_local and param_tools.get_global_parameter( @@ -141,7 +143,7 @@ class LoginView(LoginViewMixin, auth_views.LoginView): "user": escape(form.cleaned_data["username"]), } ) - return super().form_invalid(form) + return self.render_to_response(self.get_context_data(form=form), status=401) @require_http_methods(["POST"]) diff --git a/modoboa/templates/registration/login.html b/modoboa/templates/registration/login.html index c93b3bf76..3f01dc592 100644 --- a/modoboa/templates/registration/login.html +++ b/modoboa/templates/registration/login.html @@ -37,8 +37,8 @@ {% endblock %} {% block sub_content %} - {% for annoucement in annoucements %} -