Commit 78f2007b8a820cc3717f4aa29b2e0c27923c1891
Committed by
Matheus de Sousa Faria
1 parent
3a1c03ba
Exists in
master
and in
4 other branches
Send signal when password is changed
Showing
3 changed files
with
19 additions
and
3 deletions
Show diff stats
colab/accounts/urls.py
... | ... | @@ -3,7 +3,7 @@ from django.conf import settings |
3 | 3 | from django.conf.urls import patterns, url |
4 | 4 | |
5 | 5 | from .views import (UserProfileDetailView, UserProfileUpdateView, |
6 | - ManageUserSubscriptionsView) | |
6 | + ManageUserSubscriptionsView, colab_password_change) | |
7 | 7 | |
8 | 8 | from colab.accounts import views |
9 | 9 | from django.contrib.auth import views as auth_views |
... | ... | @@ -29,8 +29,7 @@ urlpatterns = patterns('', |
29 | 29 | {'template_name':'registration/password_reset_form_custom.html'}, |
30 | 30 | name="password_reset"), |
31 | 31 | |
32 | - url(r'^change-password/?$',auth_views.password_change, | |
33 | - {'template_name':'registration/password_change_form_custom.html'}, | |
32 | + url(r'^change-password/?$', colab_password_change, | |
34 | 33 | name='password_change'), |
35 | 34 | |
36 | 35 | url(r'^change-password-done/?$', | ... | ... |
colab/accounts/views.py
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | from collections import OrderedDict |
3 | 3 | |
4 | 4 | from django.contrib import messages |
5 | +from django.contrib.auth.views import password_change | |
5 | 6 | from django.db.models import Count |
6 | 7 | from django.contrib.auth import get_user_model |
7 | 8 | from django.utils.translation import ugettext as _ |
... | ... | @@ -17,6 +18,7 @@ from colab.search.utils import get_collaboration_data, get_visible_threads |
17 | 18 | from colab.accounts.models import User |
18 | 19 | |
19 | 20 | from .forms import (UserCreationForm, ListsForm, UserUpdateForm) |
21 | +from .signals import user_password_changed | |
20 | 22 | from .utils import mailman |
21 | 23 | |
22 | 24 | |
... | ... | @@ -212,3 +214,13 @@ def myaccount_redirect(request, route): |
212 | 214 | url = '/'.join(('/account', request.user.username, route)) |
213 | 215 | |
214 | 216 | return redirect(url) |
217 | + | |
218 | + | |
219 | +def colab_password_change(request): | |
220 | + template_name = 'registration/password_change_form_custom.html' | |
221 | + response = password_change(request, template_name) | |
222 | + if response.status_code == 302: | |
223 | + user_password_changed.send(sender=colab_password_change.__name__, | |
224 | + user=request.user, | |
225 | + password=request.POST.get('new_password1')) | |
226 | + return response | ... | ... |