Skip to content

Occasional error when trying to delete PasswordChangeRequired #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gBobCodes opened this issue Sep 8, 2015 · 1 comment
Closed

Occasional error when trying to delete PasswordChangeRequired #44

gBobCodes opened this issue Sep 8, 2015 · 1 comment

Comments

@gBobCodes
Copy link
Contributor

After submitting the password change form, I sometimes get this error, and sometimes the password change is successful.

AssertionError at /portal/user/mypass/
PasswordChangeRequired object can't be deleted because its id attribute is set to None.
Request Method: POST
Request URL: https://172.16.22.143/portal/user/mypass/
Django Version: 1.7.7
Exception Type: AssertionError
Exception Value:
PasswordChangeRequired object can't be deleted because its id attribute is set to None.
Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/models/base.py in delete, line 735
Python Executable: /usr/local/bin/uwsgi
Python Version: 2.7.3

/usr/local/lib/python2.7/dist-packages/password_policies/forms/init.py in save
raise forms.ValidationError(self.error_messages['password_similar'])
return cleaned_data
def save(self, commit=True):
user = super(PasswordPoliciesChangeForm, self).save(commit=commit)
try:
if user.password_change_required:
user.password_change_required.delete() ...
except ObjectDoesNotExist:
pass
return user

One solution is to check the user.password_change_required.id is not None before calling .delete().

tarak added a commit that referenced this issue Sep 8, 2015
@tarak
Copy link
Owner

tarak commented Sep 8, 2015

Closed by #45

@tarak tarak closed this as completed Sep 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants