From 925b5c238c0aa953f87cd28f10128b5f77b29bc0 Mon Sep 17 00:00:00 2001 From: Florian Aucomte <33633200+faucomte97@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:20:17 +0000 Subject: [PATCH] fix: Disable autocomplete in some forms (#2216) --- portal/forms/registration.py | 4 ++++ portal/forms/teach.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/portal/forms/registration.py b/portal/forms/registration.py index 2d71b82f7..8fee3053d 100644 --- a/portal/forms/registration.py +++ b/portal/forms/registration.py @@ -18,8 +18,10 @@ def __init__(self, user, *args, **kwargs): super(TeacherPasswordResetSetPasswordForm, self).__init__(user, *args, **kwargs) self.fields["new_password1"].help_text = "Enter your new password" self.fields["new_password1"].widget.attrs["placeholder"] = "New password" + self.fields["new_password1"].widget.attrs["autocomplete"] = "off" self.fields["new_password2"].help_text = "Confirm your new password" self.fields["new_password2"].widget.attrs["placeholder"] = "Confirm password" + self.fields["new_password2"].widget.attrs["autocomplete"] = "off" def clean_new_password1(self): return form_clean_password(self, "new_password1", PasswordStrength.TEACHER) @@ -30,8 +32,10 @@ def __init__(self, user, *args, **kwargs): super(StudentPasswordResetSetPasswordForm, self).__init__(user, *args, **kwargs) self.fields["new_password1"].help_text = "Enter your new password" self.fields["new_password1"].widget.attrs["placeholder"] = "New password" + self.fields["new_password1"].widget.attrs["autocomplete"] = "off" self.fields["new_password2"].help_text = "Confirm your new password" self.fields["new_password2"].widget.attrs["placeholder"] = "Confirm password" + self.fields["new_password2"].widget.attrs["autocomplete"] = "off" def clean_new_password1(self): return form_clean_password(self, "new_password1", PasswordStrength.INDEPENDENT) diff --git a/portal/forms/teach.py b/portal/forms/teach.py index 3d4e11fed..7d783e858 100644 --- a/portal/forms/teach.py +++ b/portal/forms/teach.py @@ -323,12 +323,12 @@ class TeacherSetStudentPass(forms.Form): password = forms.CharField( label="New password", help_text="Enter new password", - widget=forms.PasswordInput(attrs={"placeholder": "Enter new password"}), + widget=forms.PasswordInput(attrs={"autocomplete": "off", "placeholder": "Enter new password"}), ) confirm_password = forms.CharField( label="Confirm new password", help_text="Confirm new password", - widget=forms.PasswordInput(attrs={"placeholder": "Confirm new password"}), + widget=forms.PasswordInput(attrs={"autocomplete": "off", "placeholder": "Confirm new password"}), ) def clean_password(self):