You are here

function auth0_form_alter in Auth0 Single Sign On 7.2

Implements hook_form_alter().

Replace the user login forms with the Auth0 login widget.

File

./auth0.module, line 879

Code

function auth0_form_alter(&$form, $form_state, $form_id) {

  // If replacing the forms is disabled, then skip making alterations.
  if (!variable_get('auth0_replace_forms', TRUE)) {
    return;
  }
  if (($form_id == 'user_login_block' || $form_id == 'user_login') && auth0_enabled('login')) {
    _auth0_form_replace_with_lock($form, 'signin');
  }

  // If Auth0 controls the user database.
  if ($form_id == 'user_register_form' && auth0_enabled('signup')) {
    _auth0_form_replace_with_lock($form, 'signup');
  }
  if ($form_id == 'user_pass' && auth0_enabled('reset')) {
    _auth0_form_replace_with_lock($form, 'reset');
  }

  // If the settings say to remove the signup altogether.
  if (!variable_get('auth0_allow_signup', '')) {
    if ($form_id == 'user_register_form' || $form_id == 'user_pass') {

      // @TODO: Remove the user signup option.
      drupal_goto('user/login');
    }
  }
}