From b5628b646159542335ccd066dc10feedf34c2ded Mon Sep 17 00:00:00 2001 From: pavish Date: Thu, 23 Jan 2025 21:50:09 +0400 Subject: [PATCH 1/3] Fix 500 on /auth/login route after password change --- api_tests/test_happy_db_setups.py | 2 +- mathesar/urls.py | 2 +- mathesar/views/installation/complete_installation.py | 3 ++- mathesar/views/users/password_reset.py | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api_tests/test_happy_db_setups.py b/api_tests/test_happy_db_setups.py index 5b3a59f055..afa6474d0c 100644 --- a/api_tests/test_happy_db_setups.py +++ b/api_tests/test_happy_db_setups.py @@ -47,7 +47,7 @@ def intern_session(): "new_password1": "myinternpass1234", "new_password2": "myinternpass1234" } - s.post(f'{SERVICE_HOST}/auth/password_reset_confirm', data=reset_payload) + s.post(f'{SERVICE_HOST}/auth/password_reset_confirm/', data=reset_payload) s.headers['X-CSRFToken'] = s.cookies['csrftoken'] new_login_payload = {"username": "intern", "password": "myinternpass1234"} s.post(f'{SERVICE_HOST}/auth/login/', data=new_login_payload) diff --git a/mathesar/urls.py b/mathesar/urls.py index 01f40d386b..198e55a1ff 100644 --- a/mathesar/urls.py +++ b/mathesar/urls.py @@ -16,7 +16,7 @@ path('api/db/v0/', include(db_router.urls)), path('api/export/v0/tables/', views.export.export_table, name="export_table"), path('complete_installation/', installation_incomplete(CompleteInstallationFormView.as_view()), name='complete_installation'), - path('auth/password_reset_confirm', MathesarPasswordResetConfirmView.as_view(), name='password_reset_confirm'), + path('auth/password_reset_confirm/', MathesarPasswordResetConfirmView.as_view(), name='password_reset_confirm'), path('auth/login/', installation_complete(LoginView.as_view(redirect_authenticated_user=True)), name='login'), path('auth/', include('django.contrib.auth.urls')), path('', views.home, name='home'), diff --git a/mathesar/views/installation/complete_installation.py b/mathesar/views/installation/complete_installation.py index 09a7173460..4aac5f0f1a 100644 --- a/mathesar/views/installation/complete_installation.py +++ b/mathesar/views/installation/complete_installation.py @@ -1,6 +1,7 @@ from django.contrib.auth import get_user_model, login from django.contrib.auth.forms import UserCreationForm from django.views.generic import CreateView +from django.urls import reverse_lazy from django import forms from mathesar.analytics import upload_initial_report, initialize_analytics import logging @@ -47,7 +48,7 @@ def save(self, commit=True): class CompleteInstallationFormView(CreateView): template_name = "installation/complete_installation.html" form_class = CompleteInstallationForm - success_url = "/auth/login" + success_url = reverse_lazy('login') def form_valid(self, form): success = super().form_valid(form) diff --git a/mathesar/views/users/password_reset.py b/mathesar/views/users/password_reset.py index 49e93cc5f0..7a503579c7 100644 --- a/mathesar/views/users/password_reset.py +++ b/mathesar/views/users/password_reset.py @@ -4,6 +4,7 @@ from django.views.decorators.cache import never_cache from django.views.decorators.debug import sensitive_post_parameters from django.utils.translation import gettext_lazy as _ +from django.urls import reverse_lazy class MathesarSetPasswordForm(SetPasswordForm): @@ -22,7 +23,7 @@ class MathesarPasswordResetConfirmView(PasswordResetConfirmView): form_class = MathesarSetPasswordForm template_name = 'users/password_reset_confirmation.html' title = _('Change Default Password') - success_url = "/auth/login" + success_url = reverse_lazy('login') @method_decorator(sensitive_post_parameters()) @method_decorator(never_cache) From 4434ecba511160846a5693a2d5a724c1e121c00f Mon Sep 17 00:00:00 2001 From: pavish Date: Thu, 23 Jan 2025 21:59:39 +0400 Subject: [PATCH 2/3] Fix warning box style not being shown --- mathesar/templates/mathesar/login_base.html | 1 + mathesar/templates/users/password_reset_confirmation.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mathesar/templates/mathesar/login_base.html b/mathesar/templates/mathesar/login_base.html index 8d324afddf..538956ef72 100644 --- a/mathesar/templates/mathesar/login_base.html +++ b/mathesar/templates/mathesar/login_base.html @@ -53,6 +53,7 @@ display: flex; flex-direction: column; align-items: center; + gap: var(--size-xx-large); } .tutorial, .login-card, .login-card form, .login-card .footer { diff --git a/mathesar/templates/users/password_reset_confirmation.html b/mathesar/templates/users/password_reset_confirmation.html index 03cb190e02..916fe0510b 100644 --- a/mathesar/templates/users/password_reset_confirmation.html +++ b/mathesar/templates/users/password_reset_confirmation.html @@ -66,7 +66,7 @@ -
+
{% translate "After updating your password, you'll need to log in again." %}
From a2ce62200a6e28028bf555ed77f14ef706d4b242 Mon Sep 17 00:00:00 2001 From: pavish Date: Thu, 23 Jan 2025 22:03:34 +0400 Subject: [PATCH 3/3] Update position of warning message --- mathesar/templates/users/password_reset_confirmation.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mathesar/templates/users/password_reset_confirmation.html b/mathesar/templates/users/password_reset_confirmation.html index 916fe0510b..c5fb0428ed 100644 --- a/mathesar/templates/users/password_reset_confirmation.html +++ b/mathesar/templates/users/password_reset_confirmation.html @@ -63,13 +63,13 @@
{% else %}