• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/call/auth.php
  • Класс: BitrixImCallAuth
  • Вызов: Auth::authorizeById
static function authorizeById($userId, $setCookie = null, $skipAuthorizeCheck = false)
{
	global $USER;

	if (!$skipAuthorizeCheck && $USER->IsAuthorized())
	{
		return false;
	}

	$context = BitrixMainContext::getCurrent();

	if (is_null($setCookie))
	{
		$setCookie = false;
		if ($context->getRequest()->getCookieRaw('BITRIX_CALL_AUTH'))
		{
			$setCookie = true;
		}
	}

	if ($USER->GetID() != $userId)
	{
		$USER->Authorize($userId, $setCookie, $setCookie, 'public');
	}

	$cookie = new BitrixMainWebCookie('BITRIX_CALL_AUTH', 'Y', null, false);
	$cookie->setHttpOnly(false);
	$context->getResponse()->addCookie($cookie);

	$authCode = str_replace(self::AUTH_TYPE.'|', '', $USER->GetParam('XML_ID'));

	$cookie = new BitrixMainWebCookie('BITRIX_CALL_HASH', $authCode, null, false);
	$cookie->setHttpOnly(false);
	$context->getResponse()->addCookie($cookie);

	return true;
}