• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/user.php
  • Класс: CAllUser
  • Вызов: CAllUser::GeneratePhoneCode
static function GeneratePhoneCode($userId)
{
	$row = MainUserPhoneAuthTable::getRowById($userId);
	if ($row && $row["OTP_SECRET"] != '')
	{
		$totp = new MainSecurityMfaTotpAlgorithm();
		$totp->setInterval(self::PHONE_CODE_OTP_INTERVAL);
		$totp->setSecret($row["OTP_SECRET"]);

		$timecode = $totp->timecode(time());
		$code = $totp->generateOTP($timecode);

		MainUserPhoneAuthTable::update($userId, [
			"ATTEMPTS" => 0,
			"DATE_SENT" => new MainTypeDateTime(),
		]);

		return [$code, $row["PHONE_NUMBER"]];
	}
	return false;
}