From 34c28ac7a7ab8561aa5e98e01b179ca19ad12e62 Mon Sep 17 00:00:00 2001 From: Raz Date: Tue, 25 Mar 2025 06:59:55 +0100 Subject: [PATCH 1/2] fix logout and signup --- tournaments/forms.py | 2 ++ tournaments/templates/profile.html | 2 +- tournaments/urls.py | 2 +- tournaments/views.py | 5 +++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tournaments/forms.py b/tournaments/forms.py index 3cfcd21..c891afd 100644 --- a/tournaments/forms.py +++ b/tournaments/forms.py @@ -11,6 +11,7 @@ from django.contrib.sites.shortcuts import get_current_site from django.utils.encoding import force_bytes class CustomUserCreationForm(UserCreationForm): + usable_password = None class Meta: model = CustomUser @@ -30,6 +31,7 @@ class CustomUserCreationForm(UserCreationForm): fields = UserCreationForm.Meta.fields + ('umpire_code', 'clubs', 'phone', 'first_name', 'last_name', 'licence_id', 'country') class SimpleCustomUserCreationForm(UserCreationForm): + usable_password = None class Meta: model = CustomUser diff --git a/tournaments/templates/profile.html b/tournaments/templates/profile.html index 98c3fe8..89fd5f4 100644 --- a/tournaments/templates/profile.html +++ b/tournaments/templates/profile.html @@ -11,7 +11,7 @@ {% if user.is_authenticated %} Mes tournois Mon compte - Se déconnecter + Se déconnecter {% else %} Se connecter {% endif %} diff --git a/tournaments/urls.py b/tournaments/urls.py index 700c4d6..7821b39 100644 --- a/tournaments/urls.py +++ b/tournaments/urls.py @@ -62,7 +62,7 @@ urlpatterns = [ ), name='password_change' ), - path('logout/', auth_views.LogoutView.as_view(), name='logout'), + path('logout/', views.custom_logout, name='custom_logout'), path('signup/', views.signup, name='signup'), # URL pattern for signup # path('profile/', views.profile, name='profile'), # URL pattern for signup path('my-tournaments/', views.my_tournaments, name='my-tournaments'), # URL pattern for signup diff --git a/tournaments/views.py b/tournaments/views.py index 75424ab..92e62f7 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -1049,6 +1049,11 @@ def tournament_prog(request, tournament_id): } return render(request, 'tournaments/prog.html', context) +def custom_logout(request): + from django.contrib.auth import logout + logout(request) + return redirect('index') # or whatever URL you want to redirect to + class UserListExportView(LoginRequiredMixin, View): def get(self, request, *args, **kwargs): users = CustomUser.objects.order_by('date_joined') From 3c8adb56733e2aa3f2005698dcccb60ceea23d21 Mon Sep 17 00:00:00 2001 From: Raz Date: Tue, 25 Mar 2025 08:39:07 +0100 Subject: [PATCH 2/2] fix login redirect --- tournaments/templates/registration/login.html | 2 +- tournaments/templates/tournaments/navigation_base.html | 2 +- tournaments/urls.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tournaments/templates/registration/login.html b/tournaments/templates/registration/login.html index 66e056a..9a360a0 100644 --- a/tournaments/templates/registration/login.html +++ b/tournaments/templates/registration/login.html @@ -26,7 +26,7 @@ {% endfor %} {% endif %} -
+ {% csrf_token %} diff --git a/tournaments/templates/tournaments/navigation_base.html b/tournaments/templates/tournaments/navigation_base.html index 1c3337c..a92af4d 100644 --- a/tournaments/templates/tournaments/navigation_base.html +++ b/tournaments/templates/tournaments/navigation_base.html @@ -6,7 +6,7 @@ Mes tournois Mon compte {% else %} - Se connecter + Se connecter {% endif %} Ajouter vos tournois diff --git a/tournaments/urls.py b/tournaments/urls.py index 7821b39..f544567 100644 --- a/tournaments/urls.py +++ b/tournaments/urls.py @@ -54,7 +54,7 @@ urlpatterns = [ path('terms-of-use/', views.terms_of_use, name='terms-of-use'), path('utils/xls-to-csv/', views.xls_to_csv, name='xls-to-csv'), path('mail-test/', views.simple_form_view, name='mail-test'), - path('login/', CustomLoginView.as_view(), name='login'), + path('login/', CustomLoginView.as_view(), name='custom-login'), path('password_change/', auth_views.PasswordChangeView.as_view( success_url='/profile/', # Redirect back to profile after success