You are here

function _bakery_login_submit in Bakery Single Sign-On System 7.3

Same name and namespace in other branches
  1. 8.2 bakery.module \_bakery_login_submit()
  2. 6.2 bakery.module \_bakery_login_submit()
  3. 7.2 bakery.module \_bakery_login_submit()

Handle login by redirecting to master.

1 string reference to '_bakery_login_submit'
bakery_form_alter in ./bakery.module
Implements hook_form_alter().

File

./bakery.module, line 365

Code

function _bakery_login_submit($form, &$form_state) {
  global $base_url;

  // Get rid of all the values we don't explicitly know we want. While this may
  // break some modules it ensures we don't send sensitive data between sites.
  $allowed = array(
    'name',
    'pass',
    'op',
  );
  foreach ($form_state['values'] as $key => $value) {
    if (!in_array($key, $allowed)) {
      unset($form_state['values'][$key]);
    }
  }

  //form_state_values_clean($form_state); @todo ?
  $data = $form_state['values'];
  _bakery_save_destination_param($form, $data);
  unset($_GET['destination']);

  // Save query parameters to be available when user returns from master.
  $data['query'] = drupal_get_query_parameters();

  // Create cookie and redirect to master.
  $bakery = bakery_get_bakery();
  $bakery
    ->setSubCookie($data['name'], $data, $base_url . '/');
  drupal_goto(variable_get('bakery_master', 'http://drupal.org/') . 'bakery/login');
}