You are here

function tfa_store_code in Two-factor Authentication (TFA) 7

Same name and namespace in other branches
  1. 6 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_resend_code in ./tfa.pages.inc
Resend code.
tfa_user_login in ./tfa.module
Implements hook_user_login().

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' => REQUEST_TIME,
  );
  if (!$previous_code) {
    return drupal_write_record('tfa', $record);
  }
  else {
    return drupal_write_record('tfa', $record, array(
      'uid',
    ));
  }
}