You are here

function tfa_store_code in Two-factor Authentication (TFA) 6

Same name and namespace in other branches
  1. 7 tfa.module \tfa_store_code()

Store the code for state control

Parameters

int $uid UID of account.:

string $code Code to store.:

Return value

SAVED_NEW, SAVED_UPDATED or False.

2 calls to tfa_store_code()
tfa_code_form_validate in ./tfa.pages.inc
Validate handler for TFA login form.
tfa_user in ./tfa.module
Implements hook_user().

File

./tfa.module, line 251
Two-factor authentication for Drupal.

Code

function tfa_store_code($uid, $code) {
  $previous_code = tfa_get_code($uid);
  $record = array(
    'uid' => $uid,
    'code' => $code,
    'accepted' => 0,
    'created' => time(),
  );
  if (!$previous_code) {
    return drupal_write_record('tfa', $record);
  }
  else {
    return drupal_write_record('tfa', $record, array(
      'uid',
    ));
  }
}