1.20.x user.module user_login_block($form)

File

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

Code

function user_login_block($form) {
  $site_config = config('system.core');
  $credentials = $site_config->get('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,
    '#password_toggle' => TRUE,
  );
  $form['actions'] = array(
    '#type' => 'actions',
    '#weight' => 3,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Log in'),
  );
  $items = array();
  if ($site_config->get('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;
}