1 user.module user_login_block($form)

File

core/modules/user/user.module, line 1047
Enables the user registration and login system.

Code

function user_login_block($form) {
  $credentials = config_get('system.core', 'user_login_method');

  $form['#action'] = url(current_path(), array('query' => backdrop_get_destination(), 'external' => FALSE));
  $form['#id'] = 'user-login-form';
  $form['#validate'] = user_login_default_validators();
  $form['#submit'][] = 'user_login_submit';
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => $credentials === USER_LOGIN_EMAIL_ONLY ? t('Email address') : ($credentials === USER_LOGIN_USERNAME_OR_EMAIL ? t('Username or email') : t('Username')),
    '#maxlength' => $credentials === USER_LOGIN_USERNAME_ONLY ? USERNAME_MAX_LENGTH : EMAIL_MAX_LENGTH,
    '#size' => 15,
    '#required' => TRUE,
    '#weight' => 1,
  );
  $form['pass'] = array(
    '#type' => 'password',
    '#title' => t('Password'),
    '#size' => 15,
    '#required' => TRUE,
    '#weight' => 2,
  );
  $form['actions'] = array(
    '#type' => 'actions',
    '#weight' => 3,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Log in'),
  );
  $items = array();
  if (config_get('system.core', 'user_register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
    $items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'))));
  }
  $items[] = l(t('Reset password'), 'user/password', array('attributes' => array('title' => t('Reset password via one-time login link.'))));
  $form['links'] = array(
    '#theme' => 'item_list',
    '#items' => $items,
    '#weight' => 4,
  );
  return $form;
}