• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/controller/phoneauth.php
  • Класс: BitrixMainControllerPhoneAuth
  • Вызов: PhoneAuth::confirmAction
public function confirmAction($code, $signedData)
{
	global $USER;

	try
	{
		$signer = new MainSecuritySignSigner();
		$userId = $signer->unsign($signedData, static::SIGNATURE_SALT);
	}
	catch(BitrixMainSystemException $exception)
	{
		$this->addError(new MainError(Loc::getMessage('main_register_incorrect_request'), 'ERR_SIGNATURE'));
		return null;
	}

	if(!preg_match('/^[0-9]{6}$/', $code))
	{
		$this->addError(new MainError(Loc::getMessage('main_err_confirm_code_format'), 'ERR_CONFIRM_CODE'));
		return null;
	}

	$phoneRecord = MainUserPhoneAuthTable::getList([
		'filter' => [
			'=USER_ID' => $userId
		],
		'select' => ['USER_ID', 'PHONE_NUMBER', 'USER.ID', 'USER.ACTIVE'],
	])->fetchObject();

	if(!$phoneRecord)
	{
		$this->addError(new MainError(Loc::getMessage('main_register_no_user'), 'ERR_NOT_FOUND'));
		return null;
	}

	if(CUser::VerifyPhoneCode($phoneRecord->getPhoneNumber(), $code))
	{
		if($phoneRecord->getUser()->getActive() && !$USER->IsAuthorized())
		{
			$USER->Authorize($userId);
		}

		return true;
	}
	else
	{
		$this->addError(new MainError(Loc::getMessage('main_err_confirm'), 'ERR_CONFIRM_CODE'));
		return null;
	}
}