public function OAuthAddConsumerForm::submitForm in OAuth 1.0 8
Same name and namespace in other branches
- 8.2 src/Form/OAuthAddConsumerForm.php \Drupal\oauth\Form\OAuthAddConsumerForm::submitForm()
 
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ OAuthAddConsumerForm.php, line 84  - Contains \Drupal\oauth\Form\OAuthAddConsumerForm.
 
Class
- OAuthAddConsumerForm
 - Provides a form to add OAuth consumers.
 
Namespace
Drupal\oauth\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
  $consumer_key = user_password(32);
  $consumer_secret = user_password(32);
  $key_hash = sha1($consumer_key);
  $this->connection
    ->insert('oauth_consumer')
    ->fields(array(
    'uid' => $this->account
      ->id(),
    'consumer_key' => $consumer_key,
    'consumer_secret' => $consumer_secret,
    'key_hash' => $key_hash,
  ))
    ->execute();
  drupal_set_message($this
    ->t('Added a new consumer.'));
  $form_state
    ->setRedirect('oauth.user_consumer', array(
    'user' => \Drupal::currentUser()
      ->id(),
  ));
}