Skip to content

Commit

Permalink
Remove password_changed stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
davegaeddert committed Feb 13, 2024
1 parent ab99e96 commit 6446ac4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
14 changes: 0 additions & 14 deletions bolt-auth/bolt/auth/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unicodedata

from bolt.auth import password_validation
from bolt.auth.hashers import (
check_password,
hash_password,
Expand Down Expand Up @@ -98,10 +97,6 @@ class AbstractUser(models.Model):
password = models.CharField("password", max_length=128)
last_login = models.DateTimeField("last login", blank=True, null=True)

# Stores the raw password if set_password() is called so that it can
# be passed to password_changed() after the model is saved.
_password = None

objects = UserManager()

USERNAME_FIELD = "username"
Expand All @@ -119,12 +114,6 @@ def clean(self):
def __str__(self):
return self.get_username()

def save(self, *args, **kwargs):
super().save(*args, **kwargs)
if self._password is not None:
password_validation.password_changed(self._password, self)
self._password = None

def get_username(self):
"""Return the username for this User."""
return getattr(self, self.USERNAME_FIELD)
Expand All @@ -134,7 +123,6 @@ def natural_key(self):

def set_password(self, raw_password):
self.password = hash_password(raw_password)
self._password = raw_password

def check_password(self, raw_password):
"""
Expand All @@ -144,8 +132,6 @@ def check_password(self, raw_password):

def setter(raw_password):
self.set_password(raw_password)
# Password hash upgrades shouldn't be considered password changes.
self._password = None
self.save(update_fields=["password"])

return check_password(raw_password, self.password, setter)
Expand Down
12 changes: 0 additions & 12 deletions bolt-auth/bolt/auth/password_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,6 @@ def validate_password(password, user=None, password_validators=None):
raise ValidationError(errors)


def password_changed(password, user=None, password_validators=None):
"""
Inform all validators that have implemented a password_changed() method
that the password has been changed.
"""
if password_validators is None:
password_validators = get_default_password_validators()
for validator in password_validators:
password_changed = getattr(validator, "password_changed", lambda *a: None)
password_changed(password, user)


def password_validators_help_texts(password_validators=None):
"""
Return a list of all help texts of all configured validators.
Expand Down

0 comments on commit 6446ac4

Please sign in to comment.