You are here

function sms_user_authenticate in SMS Framework 7

Same name and namespace in other branches
  1. 5 modules/sms_user/sms_user.module \sms_user_authenticate()
  2. 6.2 modules/sms_user/sms_user.module \sms_user_authenticate()
  3. 6 modules/sms_user/sms_user.module \sms_user_authenticate()

Authenticates a user based on mobile number.

Parameters

string $number: The number to authenticate against. For security, this should only be provided by incoming messages, not through user input.

Return value

object|false The account that was authenticated or false if none.

2 calls to sms_user_authenticate()
SmsUserWebTest::testNumberConfirmationAndSmsUserSend in modules/sms_user/tests/sms_user.test
Tests user adding phone number.
sms_user_sms_incoming in modules/sms_user/sms_user.module
Implements hook_sms_incoming().

File

modules/sms_user/sms_user.module, line 1140
Provides integration between the SMS Framework and Drupal users.

Code

function sms_user_authenticate($number) {
  if ($uid = sms_user_get_uid($number)) {
    $account = user_load_multiple(array(
      $uid,
    ), array(
      'status' => 1,
    ));
    $account = reset($account);
    if (!empty($account)) {
      watchdog('sms_user', '%name was authenticated using SMS.', array(
        '%name' => $account->name,
      ));
      return $account;
    }
  }
  else {
    return false;
  }
}