Skip to content

Commit

Permalink
Merge pull request #4166 from mathesar-foundation/fix_4162
Browse files Browse the repository at this point in the history
Fix 500 on /auth/login route after password change
  • Loading branch information
mathemancer authored Jan 26, 2025
2 parents 9075915 + a2ce622 commit 2f153be
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api_tests/test_happy_db_setups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions mathesar/templates/mathesar/login_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions mathesar/templates/users/password_reset_confirmation.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
</label>
</div>
<div class="footer">
<button class="btn btn-primary submit-button" type="submit">
{% translate "Update Password" %}
</button>
<div class="warning-message">
<div class="message-box warning-message">
<div class="icon">&#9432;</div>
<div>{% translate "After updating your password, you'll need to log in again." %}</div>
</div>
<button class="btn btn-primary submit-button" type="submit">
{% translate "Update Password" %}
</button>
</div>
</form>
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion mathesar/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
3 changes: 2 additions & 1 deletion mathesar/views/installation/complete_installation.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion mathesar/views/users/password_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down

0 comments on commit 2f153be

Please sign in to comment.