You are here

function bakery_pull_form_validate in Bakery Single Sign-On System 7.2

Same name and namespace in other branches
  1. 6.2 bakery.module \bakery_pull_form_validate()
  2. 7.3 bakery.pages.inc \bakery_pull_form_validate()

Make sure we are not trying to request an existing user.

File

./bakery.module, line 1995
Module file for the Bakery.

Code

function bakery_pull_form_validate($form, &$form_state) {
  $existing_account = user_load_by_name($form_state['values']['name']);
  if (!$existing_account && $form_state['values']['or_email']) {
    $existing_account = user_load_by_mail($form_state['values']['name']);
  }

  // Raise an error in case the account already exists locally.
  if ($existing_account) {
    form_set_error('name', t('Account !link exists.', array(
      '!link' => theme('username', array(
        'account' => $existing_account,
      )),
    )));
  }
}