|
@@ -418,13 +418,11 @@ function user_load_by_name($name) {
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
* A fully-loaded $user object upon successful save or FALSE if the save failed.
|
|
* A fully-loaded $user object upon successful save or FALSE if the save failed.
|
|
- *
|
|
|
|
- * @todo D8: Drop $edit and fix user_save() to be consistent with others.
|
|
|
|
*/
|
|
*/
|
|
function user_save($account, $edit = array(), $category = 'account') {
|
|
function user_save($account, $edit = array(), $category = 'account') {
|
|
$transaction = db_transaction();
|
|
$transaction = db_transaction();
|
|
try {
|
|
try {
|
|
- if (!empty($edit['pass'])) {
|
|
|
|
|
|
+ if (isset($edit['pass']) && strlen(trim($edit['pass'])) > 0) {
|
|
// Allow alternate password hashing schemes.
|
|
// Allow alternate password hashing schemes.
|
|
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
|
|
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
|
|
$edit['pass'] = user_hash_password(trim($edit['pass']));
|
|
$edit['pass'] = user_hash_password(trim($edit['pass']));
|
|
@@ -791,7 +789,7 @@ function user_role_permissions($roles = array()) {
|
|
* (optional) The account to check, if not given use currently logged in user.
|
|
* (optional) The account to check, if not given use currently logged in user.
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
- * Boolean TRUE if the current user has the requested permission.
|
|
|
|
|
|
+ * Boolean TRUE if the user has the requested permission.
|
|
*
|
|
*
|
|
* All permission checks in Drupal should go through this function. This
|
|
* All permission checks in Drupal should go through this function. This
|
|
* way, we guarantee consistent behavior, and ensure that the superuser
|
|
* way, we guarantee consistent behavior, and ensure that the superuser
|
|
@@ -1162,7 +1160,7 @@ function user_account_form(&$form, &$form_state) {
|
|
$form['account']['roles'] = array(
|
|
$form['account']['roles'] = array(
|
|
'#type' => 'checkboxes',
|
|
'#type' => 'checkboxes',
|
|
'#title' => t('Roles'),
|
|
'#title' => t('Roles'),
|
|
- '#default_value' => (!$register && isset($account->roles) ? array_keys($account->roles) : array()),
|
|
|
|
|
|
+ '#default_value' => (!$register && !empty($account->roles) ? array_keys(array_filter($account->roles)) : array()),
|
|
'#options' => $roles,
|
|
'#options' => $roles,
|
|
'#access' => $roles && user_access('administer permissions'),
|
|
'#access' => $roles && user_access('administer permissions'),
|
|
DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,
|
|
DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,
|
|
@@ -1232,7 +1230,7 @@ function user_validate_current_pass(&$form, &$form_state) {
|
|
// that prevent them from being empty if they are changed.
|
|
// that prevent them from being empty if they are changed.
|
|
if ((strlen(trim($form_state['values'][$key])) > 0) && ($form_state['values'][$key] != $account->$key)) {
|
|
if ((strlen(trim($form_state['values'][$key])) > 0) && ($form_state['values'][$key] != $account->$key)) {
|
|
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
|
|
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
|
|
- $current_pass_failed = empty($form_state['values']['current_pass']) || !user_check_password($form_state['values']['current_pass'], $account);
|
|
|
|
|
|
+ $current_pass_failed = strlen(trim($form_state['values']['current_pass'])) == 0 || !user_check_password($form_state['values']['current_pass'], $account);
|
|
if ($current_pass_failed) {
|
|
if ($current_pass_failed) {
|
|
form_set_error('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name)));
|
|
form_set_error('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name)));
|
|
form_set_error($key);
|
|
form_set_error($key);
|
|
@@ -1755,9 +1753,11 @@ function user_menu() {
|
|
|
|
|
|
$items['admin/people/create'] = array(
|
|
$items['admin/people/create'] = array(
|
|
'title' => 'Add user',
|
|
'title' => 'Add user',
|
|
|
|
+ 'page callback' => 'user_admin',
|
|
'page arguments' => array('create'),
|
|
'page arguments' => array('create'),
|
|
'access arguments' => array('administer users'),
|
|
'access arguments' => array('administer users'),
|
|
'type' => MENU_LOCAL_ACTION,
|
|
'type' => MENU_LOCAL_ACTION,
|
|
|
|
+ 'file' => 'user.admin.inc',
|
|
);
|
|
);
|
|
|
|
|
|
// Administration pages.
|
|
// Administration pages.
|
|
@@ -2165,7 +2165,7 @@ function user_login_name_validate($form, &$form_state) {
|
|
*/
|
|
*/
|
|
function user_login_authenticate_validate($form, &$form_state) {
|
|
function user_login_authenticate_validate($form, &$form_state) {
|
|
$password = trim($form_state['values']['pass']);
|
|
$password = trim($form_state['values']['pass']);
|
|
- if (!empty($form_state['values']['name']) && !empty($password)) {
|
|
|
|
|
|
+ if (!empty($form_state['values']['name']) && strlen(trim($password)) > 0) {
|
|
// Do not allow any login from the current user's IP if the limit has been
|
|
// Do not allow any login from the current user's IP if the limit has been
|
|
// reached. Default is 50 failed attempts allowed in one hour. This is
|
|
// reached. Default is 50 failed attempts allowed in one hour. This is
|
|
// independent of the per-user limit to catch attempts from one IP to log
|
|
// independent of the per-user limit to catch attempts from one IP to log
|
|
@@ -2256,7 +2256,7 @@ function user_login_final_validate($form, &$form_state) {
|
|
*/
|
|
*/
|
|
function user_authenticate($name, $password) {
|
|
function user_authenticate($name, $password) {
|
|
$uid = FALSE;
|
|
$uid = FALSE;
|
|
- if (!empty($name) && !empty($password)) {
|
|
|
|
|
|
+ if (!empty($name) && strlen(trim($password)) > 0) {
|
|
$account = user_load_by_name($name);
|
|
$account = user_load_by_name($name);
|
|
if ($account) {
|
|
if ($account) {
|
|
// Allow alternate password hashing schemes.
|
|
// Allow alternate password hashing schemes.
|