Skip to content

Commit

Permalink
[#1178] The user is activated when it performs the reset password
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorbaptista committed Aug 14, 2013
1 parent a492bad commit 6999429
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions ckan/controllers/user.py
Expand Up @@ -479,6 +479,7 @@ def perform_reset(self, id):
new_password = self._get_form_password()
user_dict['password'] = new_password
user_dict['reset_key'] = c.reset_key
user_dict['state'] = model.State.ACTIVE
user = get_action('user_update')(context, user_dict)

h.flash_success(_("Your password has been reset."))
Expand Down
18 changes: 18 additions & 0 deletions ckan/tests/functional/test_user.py
Expand Up @@ -955,3 +955,21 @@ def test_perform_reset_user_password_link_user_incorrect(self):
id='randomness', # i.e. incorrect
key='randomness')
res = self.app.get(offset, status=404)

def test_perform_reset_activates_pending_user(self):
password = 'password'
params = { 'password1': password, 'password2': password }
user = CreateTestData.create_user(name='username',
email='user@email.com')
user.set_pending()
create_reset_key(user)
assert user.is_pending(), user.state

offset = url_for(controller='user',
action='perform_reset',
id=user.id,
key=user.reset_key)
res = self.app.post(offset, params=params, status=302)

user = model.User.get(user.id)
assert user.is_active(), user

0 comments on commit 6999429

Please sign in to comment.