|
|
|
|
@ -53,7 +53,7 @@ from django.contrib.auth.forms import ( |
|
|
|
|
SetPasswordForm, |
|
|
|
|
) |
|
|
|
|
from django.contrib.auth.views import PasswordResetConfirmView |
|
|
|
|
from django.contrib.auth.models import User |
|
|
|
|
from django.contrib.auth import get_user_model |
|
|
|
|
from django.contrib.auth.tokens import default_token_generator |
|
|
|
|
from django.db.models import Q |
|
|
|
|
from django.views.decorators.csrf import csrf_exempt |
|
|
|
|
@ -659,26 +659,15 @@ def unregister_tournament(request, tournament_id): |
|
|
|
|
return redirect('tournament-info', tournament_id=tournament_id) |
|
|
|
|
|
|
|
|
|
class CustomPasswordResetConfirmView(PasswordResetConfirmView): |
|
|
|
|
template_name = 'registration/password_reset_confirm.html' # Custom template |
|
|
|
|
template_name = 'registration/password_reset_confirm.html' |
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
|
""" |
|
|
|
|
Modify the context to provide custom data to the template. |
|
|
|
|
""" |
|
|
|
|
context = super().get_context_data(**kwargs) |
|
|
|
|
context['custom_message'] = "Veuillez entrer un nouveau mot de passe." |
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
def form_valid(self, form): |
|
|
|
|
""" |
|
|
|
|
Custom behavior when the password reset form is valid. |
|
|
|
|
""" |
|
|
|
|
# Call the parent method to save the new password |
|
|
|
|
response = super().form_valid(form) |
|
|
|
|
|
|
|
|
|
# Additional actions (e.g., logging or sending notifications) can be added here |
|
|
|
|
# You can add custom logic after password reset |
|
|
|
|
|
|
|
|
|
return response |
|
|
|
|
|
|
|
|
|
def get_user(self, uidb64): |
|
|
|
|
@ -686,6 +675,9 @@ class CustomPasswordResetConfirmView(PasswordResetConfirmView): |
|
|
|
|
Override this method to decode the uid and return the corresponding user. |
|
|
|
|
""" |
|
|
|
|
try: |
|
|
|
|
# Use get_user_model() instead of direct User import |
|
|
|
|
User = get_user_model() |
|
|
|
|
|
|
|
|
|
uid = urlsafe_base64_decode(uidb64).decode() |
|
|
|
|
user = User.objects.get(pk=uid) |
|
|
|
|
return user |
|
|
|
|
|