You are here

function tfa_send_code in Two-factor Authentication (TFA) 7

Same name and namespace in other branches
  1. 6 tfa.module \tfa_send_code()

Send the code to the user.

Parameters

object $account User account.:

Return value

bool True or False if the code was sent on the secondary channel.

1 call to tfa_send_code()
tfa_tfa_process in ./tfa.module
Send the code and redirect to entry form.

File

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

Code

function tfa_send_code($account) {
  $code = tfa_get_code($account->uid);
  $code = $code['code'];

  // Actual code is within element 'code'.
  $message = check_plain(variable_get('tfa_send_message', 'Login code'));

  // Variable send method, defaults to TFA method using SMS Framework.
  $module = variable_get('tfa_channel', 'sms');
  $function = $module . '_tfa_api';
  if (!empty($module) && function_exists($function)) {
    $channel = $function();
    $function = $channel['send callback'];
    $result = $function($account, $code, $message);
    return $result;
  }
  return FALSE;
}