function apigee_edge_form_user_form_api_connection_validate in Apigee Edge 8
Validates whether there is connection to Apigee Edge or not.
Parameters
array $form: Form array.
Drupal\Core\Form\FormStateInterface $form_state: Form state object.
2 string references to 'apigee_edge_form_user_form_api_connection_validate'
- apigee_edge_form_user_form_alter in ./
apigee_edge.module - Implements hook_form_FORM_ID_alter().
- apigee_edge_form_user_register_form_alter in ./
apigee_edge.module - Implements hook_form_FORM_ID_alter().
File
- ./
apigee_edge.module, line 858 - Copyright 2018 Google Inc.
Code
function apigee_edge_form_user_form_api_connection_validate(array $form, FormStateInterface $form_state) {
// If there is no connection to Apigee Edge interrupt the registration/user
// update, otherwise it could be a security leak if a developer exists in
// Apigee Edge with the same email address.
/** @var \Drupal\apigee_edge\SDKConnectorInterface $sdk_connector */
$sdk_connector = \Drupal::service('apigee_edge.sdk_connector');
try {
$sdk_connector
->testConnection();
} catch (\Exception $exception) {
$context = [
'@user_email' => $form_state
->getValue('mail'),
'@message' => (string) $exception,
];
watchdog_exception('apigee_edge', $exception, 'Could not create/update Drupal user: @user_email, because there was no connection to Apigee Edge. @message %function (line %line of %file). <pre>@backtrace_string</pre>', $context);
$form_state
->setError($form, t('User registration is temporarily unavailable. Try again later or contact the site administrator.'));
}
}