Add change password endpoint

This commit is contained in:
Matt Wright
2013-02-01 18:21:43 -05:00
parent f1f621d178
commit adb2680289
6 changed files with 18 additions and 15 deletions
+3 -1
View File
@@ -4,7 +4,7 @@ Flask-Security Changelog
Here you can see the full list of changes between each Flask-Security release.
Version 1.5.5
Version 1.6.0
-------------
Not yet released
@@ -13,6 +13,8 @@ Not yet released
- Flask-Login messages are configurable
- AJAX requests must now send a CSRF token for security reasons
- Login form messages are now configurable
- Forms can now be extended with more fields
- Added change password endpoint
Version 1.5.4
+2 -2
View File
@@ -81,11 +81,11 @@ class UserDatastore(object):
kwargs['roles'] = roles
return kwargs
def find_user(self, **kwargs):
def find_user(self, *args, **kwargs):
"""Returns a user matching the provided parameters."""
raise NotImplementedError
def find_role(self, name):
def find_role(self, *args, **kwargs):
"""Returns a role matching the provided name."""
raise NotImplementedError
+5 -5
View File
@@ -331,7 +331,7 @@ class ChangePasswordTest(SecurityTest):
def test_change_password_invalid(self):
self.authenticate()
r = self.client.post('/change', data={
r = self._post('/change', data={
'password': 'notpassword',
'new_password': 'newpassword',
'new_password_confirm': 'newpassword'
@@ -341,7 +341,7 @@ class ChangePasswordTest(SecurityTest):
def test_change_password_mismatch(self):
self.authenticate()
r = self.client.post('/change', data={
r = self._post('/change', data={
'password': 'password',
'new_password': 'newpassword',
'new_password_confirm': 'notnewpassword'
@@ -351,7 +351,7 @@ class ChangePasswordTest(SecurityTest):
def test_change_password_bad_password(self):
self.authenticate()
r = self.client.post('/change', data={
r = self._post('/change', data={
'password': 'password',
'new_password': 'a',
'new_password_confirm': 'a'
@@ -362,7 +362,7 @@ class ChangePasswordTest(SecurityTest):
def test_change_password_success(self):
self.authenticate()
with self.app.extensions['mail'].record_messages() as outbox:
r = self.client.post('/change', data={
r = self._post('/change', data={
'password': 'password',
'new_password': 'newpassword',
'new_password_confirm': 'newpassword'
@@ -385,7 +385,7 @@ class ChangePasswordPostViewTest(SecurityTest):
def test_change_password_success(self):
self.authenticate()
r = self.client.post('/change', data={
r = self._post('/change', data={
'password': 'password',
'new_password': 'newpassword',
'new_password_confirm': 'newpassword'
+4 -4
View File
@@ -224,11 +224,11 @@ class MongoEngineSecurityTests(DefaultSecurityTests):
return create_app(auth_config, **kwargs)
class PeeweeSecurityTests(DefaultSecurityTests):
# class PeeweeSecurityTests(DefaultSecurityTests):
def _create_app(self, auth_config, **kwargs):
from tests.test_app.peewee_app import create_app
return create_app(auth_config, **kwargs)
# def _create_app(self, auth_config, **kwargs):
# from tests.test_app.peewee_app import create_app
# return create_app(auth_config, **kwargs)
class DefaultDatastoreTests(SecurityTest):
+2 -1
View File
@@ -165,7 +165,8 @@ class ChangeableSignalsTests(SecurityTest):
client.post('/change',
data=dict(password='password',
new_password='newpassword',
new_password_confirm='newpassword'))
new_password_confirm='newpassword',
csrf_token=self.csrf_token))
self.assertEqual(mocks.signals_sent(), set([password_changed]))
user = self.app.security.datastore.find_user(email='joe@lp.com')
calls = mocks[password_changed]
+2 -2
View File
@@ -55,8 +55,8 @@ class DatastoreTests(unittest.TestCase):
self.assertRaises(NotImplementedError, ds.delete, None)
def test_unimplemented_user_datastore_methods(self):
self.assertRaises(NotImplementedError, self.ds.find_user)
self.assertRaises(NotImplementedError, self.ds.find_role)
self.assertRaises(NotImplementedError, self.ds.find_user, None)
self.assertRaises(NotImplementedError, self.ds.find_role, None)
def test_toggle_active(self):
user.active = True