add in change password into the user log (bug 624884)

This commit is contained in:
Andy McKay 2011-05-27 10:19:20 -07:00
Родитель 79c773c9b9
Коммит a9df86ce71
4 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -357,6 +357,12 @@ class BULK_VALIDATION_EMAILED(_LOG):
format = _(u'Authors emailed about compatibility of {version}.')
class CHANGE_PASSWORD(_LOG):
id = 48
action_class = None
format = _(u'Password changed.')
class CUSTOM_TEXT(_LOG):
id = 98
action_class = None

Просмотреть файл

@ -11,6 +11,7 @@ import commonware.log
import happyforms
from tower import ugettext as _, ugettext_lazy as _lazy
import amo
from amo.utils import slug_validator
from .models import (UserProfile, BlacklistedUsername, BlacklistedEmailDomain,
DjangoUser)
@ -57,6 +58,7 @@ class SetPasswordForm(auth_forms.SetPasswordForm):
self.user = self.user.get_profile()
def save(self, **kw):
amo.log(amo.LOG.CHANGE_PASSWORD, user=self.user)
log.info(u'User (%s) changed password with reset form' % self.user)
super(SetPasswordForm, self).save(**kw)
@ -226,6 +228,7 @@ class UserEditForm(UserRegisterForm):
if data['password']:
u.set_password(data['password'])
amo.log(amo.LOG.CHANGE_PASSWORD)
log.info(u'User (%s) changed their password' % u)
log.debug(u'User (%s) updated their profile' % u)

Просмотреть файл

@ -11,6 +11,7 @@ from manage import settings
from mock import Mock, patch
from nose.tools import eq_
import amo
from amo.helpers import urlparams
from amo.urlresolvers import reverse
from amo.tests.test_helpers import get_uploaded_file
@ -65,6 +66,9 @@ class TestSetPasswordForm(UserFormBase):
self.user_profile = User.objects.get(id='4043307').get_profile()
assert self.user_profile.check_password('testo')
eq_(self.user_profile.userlog_set
.filter(activity_log__action=amo.LOG.CHANGE_PASSWORD.id)
.count(), 1)
class TestPasswordResetForm(UserFormBase):

Просмотреть файл

@ -12,6 +12,7 @@ from pyquery import PyQuery as pq
from access.models import Group, GroupUser
from addons.models import Addon, AddonUser
import amo
from amo.helpers import urlparams
from amo.pyquery_wrapper import PyQuery
from amo.urlresolvers import reverse
@ -54,8 +55,18 @@ class TestEdit(UserViewBase):
def setUp(self):
super(TestEdit, self).setUp()
self.client.login(username='jbalogh@mozilla.com', password='foo')
self.user = UserProfile.objects.get(username='jbalogh')
self.url = reverse('users.edit')
def test_password_logs(self):
data = {'username': 'jbalogh', 'email': 'jbalogh@mozilla.com',
'oldpassword': 'foo', 'password': 'bar', 'password2': 'bar'}
res = self.client.post(self.url, data)
eq_(res.status_code, 302)
eq_(self.user.userlog_set
.filter(activity_log__action=amo.LOG.CHANGE_PASSWORD.id)
.count(), 1)
def test_email_change_mail_sent(self):
data = {'username': 'jbalogh',
'email': 'jbalogh.changed@mozilla.com',