You are here

protected function TfaTotpSetup::storeSeed in TFA Basic plugins 7

Save seed for account.

Parameters

string $seed Seed.:

1 call to TfaTotpSetup::storeSeed()
TfaTotpSetup::submitSetupForm in includes/tfa_totp.inc
@copydoc TfaSetupPluginInterface::submitSetupForm()

File

includes/tfa_totp.inc, line 304
classes for tfa_totp

Class

TfaTotpSetup
Class TfaTotpSetup

Code

protected function storeSeed($seed) {

  // Encrypt seed for storage.
  $encrypted = $this
    ->encrypt($seed);

  // Data is binary so store base64 encoded.
  $record = array(
    'uid' => $this->context['uid'],
    'seed' => base64_encode($encrypted),
    'created' => REQUEST_TIME,
  );
  $existing = $this
    ->getSeed();
  if (!empty($existing)) {

    // Update existing seed.
    drupal_write_record('tfa_totp_seed', $record, 'uid');
  }
  else {
    drupal_write_record('tfa_totp_seed', $record);
  }
}