You are here

function bakery_profile_pull_form_validate in Bakery Single Sign-On System 7.4

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

File

./bakery_profile.module, line 401

Code

function bakery_profile_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,
      )),
    )));
  }
}