• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/authentication/device.php
  • Класс: BitrixMainAuthenticationDevice
  • Вызов: Device::addLogin
static function addLogin(Context $context, array $user): void
{
	$device = static::findByCookie($context);

	if ($device === null)
	{
		$cookable = false;
		$device = static::findByUserAgent($context);
	}
	else
	{
		// found by a cookie = supports cookies
		$cookable = true;
	}

	if ($device === null)
	{
		// add a new device for the user
		$device = static::add($context);
		$deviceLogin = static::addDeviceLogin($device, $context);

		if (Option::get('main', 'user_device_notify', 'N') === 'Y')
		{
			// send notification to the user
			static::sendEmail($device, $deviceLogin, $user);
		}
	}
	else
	{
		// update to actual data
		static::update($device, $cookable);
		static::addDeviceLogin($device, $context);
	}

	static::setCookie($device->getDeviceUid());
}