| 105 | |
| 106 | @sensitive_variables("password1", "password2") |
| 107 | def validate_passwords( |
| 108 | self, |
| 109 | password1_field_name="password1", |
| 110 | password2_field_name="password2", |
| 111 | ): |
| 112 | password1 = self.cleaned_data.get(password1_field_name) |
| 113 | password2 = self.cleaned_data.get(password2_field_name) |
| 114 | |
| 115 | if password1 and password2 and password1 != password2: |
| 116 | error = ValidationError( |
| 117 | self.error_messages["password_mismatch"], |
| 118 | code="password_mismatch", |
| 119 | ) |
| 120 | self.add_error(password2_field_name, error) |
| 121 | |
| 122 | @sensitive_variables("password") |
| 123 | def validate_password_for_user(self, user, password_field_name="password2"): |