Prevent the 'change passwd' view from crashing

This commit is contained in:
Martin Pépin 2020-09-12 14:22:20 +02:00
parent 7a7979c91a
commit 7c281f926b
No known key found for this signature in database
GPG key ID: E7520278B1774448

View file

@ -63,22 +63,20 @@ def change_membre(request):
user_form = ChangeFormUser(instance=request.user)
return render(request, 'gestion/change.html', locals())
@login_required
def change_password(request):
success = False
if request.method == 'POST':
requbis = request.POST.copy()
form = PasswordChangeForm(request.user, data=requbis)
form = PasswordChangeForm(request.user, data=request.POST)
if form.is_valid():
request.user.profile.photo.delete()
form.save()
success = True
else:
form = PasswordChangeForm(request.user)
return render(request, 'gestion/changepasswd.html', locals())
return render(
request, 'gestion/changepasswd.html', {"form": form, "success": success}
)
def inscription_membre(request):