From d1f26518a39f1148f734bfc199702fbce58f6beb Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sun, 7 Mar 2010 18:46:55 +0000 Subject: [PATCH] #677766 by matason and atheneus: Fixed Account gets blocked when user edits their profile. (with tests) --- modules/user/user.module | 4 ++-- modules/user/user.test | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/modules/user/user.module b/modules/user/user.module index 135ef3573cc..aaa9fd3b65e 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -998,10 +998,10 @@ function user_account_form(&$form, &$form_state) { } if ($admin) { - $status = (isset($account->status) ? $account->status : 1); + $status = isset($account->status) ? $account->status : 1; } else { - $status = (variable_get('user_register', 1) == 1); + $status = $register ? variable_get('user_register', 1) == 1 : $account->status; } $form['account']['status'] = array( '#type' => 'radios', diff --git a/modules/user/user.test b/modules/user/user.test index 70925ad8c59..cc1e0cb96a9 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -1421,3 +1421,39 @@ class UserEditTestCase extends DrupalWebTestCase { $this->drupalLogout(); } } + +/** + * Test that a user, having editing their own account, can still log in. + */ +class UserEditedOwnAccountTestCase extends DrupalWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'User edited own account', + 'description' => 'Test user edited own account can still log in.', + 'group' => 'User', + ); + } + + function testUserEditedOwnAccount() { + // Change account setting 'Who can register accounts?' to Administrators + // only. + variable_set('user_register', 0); + + // Create a new user account and log in. + $account = $this->drupalCreateUser(array('change own username')); + $this->drupalLogin($account); + + // Change own username. + $edit = array(); + $edit['name'] = $this->randomName(); + $this->drupalPost('user/' . $account->uid . '/edit', $edit, t('Save')); + + // Log out. + $this->drupalLogout(); + + // Set the new name on the user account and attempt to log back in. + $account->name = $edit['name']; + $this->drupalLogin($account); + } +} \ No newline at end of file