Skip to content

Commit

Permalink
Merge branch '2866-missing-reset-key'
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Aug 16, 2012
2 parents 0ae6671 + 5e338d9 commit f314b5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ckan/lib/mailer.py
Expand Up @@ -95,6 +95,8 @@ def send_reset_link(user):
mail_user(user, _('Reset your password'), body)

def verify_reset_link(user, key):
if not key:
return False
if not user.reset_key or len(user.reset_key) < 5:
return False
return key.strip() == user.reset_key
Expand Down
9 changes: 9 additions & 0 deletions ckan/tests/functional/test_user.py
Expand Up @@ -965,6 +965,15 @@ def test_perform_reset_user_password_link_key_incorrect(self):
key='randomness') # i.e. incorrect
res = self.app.get(offset, status=403) # error

def test_perform_reset_user_password_link_key_missing(self):
CreateTestData.create_user(name='jack', password='test1')
user = model.User.by_name(u'jack')
offset = url_for(controller='user',
action='perform_reset',
id=user.id) # not, no key specified
res = self.app.get(offset, status=403) # error


def test_perform_reset_user_password_link_user_incorrect(self):
# Make up a key - i.e. trying to hack this
user = model.User.by_name(u'jack')
Expand Down

0 comments on commit f314b5e

Please sign in to comment.