Skip to content

Commit

Permalink
Merge pull request #45 from HuskerBob/master
Browse files Browse the repository at this point in the history
Fixes #43 and #44.
  • Loading branch information
tarak committed Sep 8, 2015
2 parents bb959b9 + 276451d commit 76c8066
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions password_policies/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def save(self, commit=True):
self.user.set_password(new_password)
if commit:
self.user.save()
if settings.PASSWORD_USE_HISTORY:
password = make_password(new_password)
PasswordHistory.objects.create(password=password, user=self.user)
PasswordHistory.objects.delete_expired(self.user)
PasswordChangeRequired.objects.filter(user=self.user).delete()
if settings.PASSWORD_USE_HISTORY:
password = make_password(new_password)
PasswordHistory.objects.create(password=password, user=self.user)
PasswordHistory.objects.delete_expired(self.user)
PasswordChangeRequired.objects.filter(user=self.user).delete()
return self.user


Expand Down Expand Up @@ -155,7 +155,8 @@ def clean(self):
def save(self, commit=True):
user = super(PasswordPoliciesChangeForm, self).save(commit=commit)
try:
if user.password_change_required:
# Checking the object id to prevent AssertionError id is None when deleting.
if user.password_change_required and user.password_change_required.id:
user.password_change_required.delete()
except ObjectDoesNotExist:
pass
Expand Down

0 comments on commit 76c8066

Please sign in to comment.