/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $email = $form_state->getValue('email'); $pass = $form_state->getValue('pass'); $name = \Drupal::config('system.site')->get('name'); try { Lockr::site()->register($email, $pass, $name); } catch (ClientException $e) { drupal_set_message($this->t('Login credentials incorrect, please try again.'), 'error'); return; } catch (ServerException $e) { drupal_set_message($this->t('An unknown error has occurred, please try again later.'), 'error'); return; } drupal_set_message($this->t("That's it! You're signed up with Lockr; your keys are now safe.")); $form_state->setRedirect($form_state->get('destination')); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $email = $form_state->getValue('email'); $destination = $form_state->get('destination'); $name = \Drupal::config('system.site')->get('name'); try { Lockr::site()->register($email, null, $name); } catch (ClientException $e) { drupal_set_message($this->t('This email is already registered with Lockr. ' . 'Please login to register a new site.')); $form_state->setRedirect('lockr.login', [], ['query' => ['email' => $email, 'destination' => $destination]]); return; } catch (ServerException $e) { $form_state->setErrorByName('', $this->t('An unknown error has occurred, please try again later.')); return; } drupal_set_message($this->t("That's it! You're signed up with Lockr; your keys are now safe.")); $form_state->setRedirect($destination); }
/** * {@inheritdoc} */ public function deleteKeyValue(KeyInterface $key) { $name = $key->id(); $client = Lockr::key(); try { $client->delete($name); } catch (\Exception $e) { return FALSE; } return TRUE; }