• Модуль: security
  • Путь к файлу: ~/bitrix/modules/security/lib/mfa/otp.php
  • Класс: BitrixSecurityMfaOtp
  • Вызов: Otp::save
public function save()
{
	$fields = array(
		'ACTIVE' => $this->isActivated()? 'Y': 'N',
		'TYPE' => $this->getType(),
		'ATTEMPTS' => $this->getAttempts(),
		'SECRET' => $this->getHexSecret(),
		'INITIAL_DATE' => $this->getInitialDate()?: new TypeDateTime,
		'PARAMS' => $this->getParams(),
		'SKIP_MANDATORY' => $this->isMandatorySkipped()? 'Y': 'N',
		'DEACTIVATE_UNTIL' => $this->getDeactivateUntil()
	);

	if ($this->regenerated)
	{
		if (!$this->isInitialized())
			throw new OtpException('Missing OTP params, forgot to call syncParameters?');

		// Clear recovery codes when we connect new device
		RecoveryCodesTable::clearByUser($this->getUserId());
	}


	if ($this->isDbRecordExists())
	{
		$result = UserTable::update($this->getUserId(), $fields);
	}
	else
	{
		$fields += array(
			'USER_ID' => $this->getUserId(),
		);
		$result = UserTable::add($fields);
	}

	$this->clearGlobalCache();

	return $result->isSuccess();
}