Wednesday, October 24, 2012

Re: Best way to detect if a user has changed password

You could use a "pre_save" signal. kwargs['instance'] will contain the updated record and you can get the old record with "User.objects.get(id=user.id) if user.pk else None". I've done this in the past to check for a changed email address.

On Wed, Oct 24, 2012 at 2:23 PM, Roarster <ianstrachan2008@gmail.com> wrote:
I'm running a Django 1.4 site and I have some operations I want to perform if a user changes their password.  I'm using the standard contrib.auth user accounts with the normal password_change view and I'm not sure if I should somehow hook into this view or if I should use a signal on post_save for the user.  If I do use the signal, is it possible to tell when the password has been changed?  I do feel that if I can use a signal this might be the best approach since it would handle any other password change mechanisms that I might add later without any extra work.

Does anyone have any ideas on the best way to do this?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/yrhcGbYf0f4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment