• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/authentication/shortcode.php
  • Класс: BitrixMainAuthenticationShortCode
  • Вызов: ShortCode::verify
public function verify($code)
{
	$result = new MainResult();

	$attempts = (int)$this->code->getAttempts();

	if($attempts >= 3)
	{
		$result->addError(new MainError("Retry count exceeded.", "ERR_RETRY_COUNT"));
		return $result;
	}

	$totp = new MainSecurityMfaTotpAlgorithm();
	$totp->setInterval($this->checkInterval);
	$totp->setSecret($this->code->getOtpSecret());

	$otpResult = false;
	try
	{
		list($otpResult, ) = $totp->verify($code);
	}
	catch(MainArgumentException $e)
	{
	}

	if($otpResult)
	{
		$this->code->setDateSent(null);
		$this->code->setDateResent(null);
	}
	else
	{
		$result->addError(new MainError("Incorrect code.", "ERR_CONFIRM_CODE"));

		$this->code->setAttempts($attempts + 1);
	}

	$this->code->save();

	return $result;
}