public function LockrLoginForm::submitForm in Lockr 8.2
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/ LockrLoginForm.php, line 126 - Contains Drupal\lockr\Form\LockrLoginForm.
Class
Namespace
Drupal\lockr\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$email = $form_state
->getValue('email');
$pass = $form_state
->getValue('pass');
$name = $this->config
->get('system.site')
->get('name');
$site_client = $this->clientFactory
->getSiteClient();
try {
$site_client
->register($email, $pass, $name);
} catch (LockrClientException $e) {
if ($e->title === 'Partner mismatch') {
$msg = $this
->t("We didn't recognize your certificate, please ensure the provide path is a valid Lockr certificate.");
}
elseif ($e->title === 'Site exists') {
$msg = $this
->t('This site is already registered. If you are experiencing issues, please contact support@lockr.io.');
}
elseif ($e->title === 'Credentials invalid') {
$msg = $this
->t('The username and password did not match, please try again.');
}
else {
$msg = $this
->t('An unknown error occurred, please try again later.');
}
drupal_set_message($msg, 'error');
return;
} catch (LockrException $e) {
$msg = $this
->t('An unknown error occurred, please try again later.');
drupal_set_message($msg, 'error');
return;
}
drupal_set_message($this
->t("That's it! You're signed up with Lockr; your keys are now safe."));
$form_state
->setRedirect('entity.key.collection');
}