You are here

function lockr_admin_register_form_submit in Lockr 7.3

File

./lockr.admin.inc, line 166
Form callbacks for Lockr register form.

Code

function lockr_admin_register_form_submit($form, &$form_state) {
  $client_token = $form_state['values']['client_token'];
  $lc = lockr_client();
  $partner = lockr_get_partner();
  try {
    if (is_null($partner)) {
      $dn = [
        'countryName' => 'US',
        'stateOrProvinceName' => 'Washington',
        'localityName' => 'Tacoma',
        'organizationName' => 'Lockr',
      ];
      $result = $lc
        ->createCertClient($client_token, $dn);
      $dir = "private://lockr/dev";
      _lockr_write_key_files($dir, $result);
      $private_wrapper = new DrupalPrivateStreamWrapper();
      $private_wrapper
        ->setUri("{$dir}/pair.pem");
      variable_set('lockr_cert', $private_wrapper
        ->realpath());
      variable_set('lockr_custom', TRUE);
    }
    else {
      if ($partner['name'] === 'pantheon') {
        $lc
          ->createPantheonClient($client_token);
      }
    }
  } catch (\Exception $e) {
    form_set_error('', t('An unknown error has occurred, please try again later.'));
    return;
  }
  drupal_set_message(t("That's it! You're signed up with Lockr; your keys can now be safely stored off-site."));
}