82 foreach(static::$authQueryParams as $key)
84 if(array_key_exists($key, $query))
86 $authCode = $query[$key];
91 if ($authCode ===
null)
97 $method = \CRestServer::instance()->getMethod();
98 if ($method === self::PASSWORD_CHECK_METHOD)
102 if (!$conference || !$conference->isActive())
105 'error' =>
'CALL_AUTH_NOT_ACTIVE',
106 'error_description' =>
'Call: conference is not active',
115 $storage = \Bitrix\Main\Application::getInstance()->getLocalSession(
'conference_check_' . $query[
'videoconf_id']);
116 if($storage->get(
'checked') ===
true)
124 if (!$conference || !$conference->isActive())
127 'error' =>
'CALL_AUTH_VIDEOCONF_NOT_ACTIVE',
128 'error_description' =>
'Call: conference is not active',
135 if ($conference->isPasswordRequired())
137 if ($conference->getPassword() === $query[
'videoconf_password'])
139 $storage->set(
'checked',
true);
144 'error' =>
'CALL_AUTH_ACCESS_DENIED',
145 'error_description' =>
'Call: access to conference is denied',
155 if ($authCode == self::AUTH_CODE_GUEST)
157 if (self::checkQueryMethod(self::METHODS_WITHOUT_AUTH))
159 $res = self::getSuccessfulResult();
166 'error' =>
'CALL_AUTH_METHOD_ERROR',
167 'error_description' =>
'Call: you don\'t have access to use this method [1]',
174 else if (!preg_match(
"/^[a-fA-F0-9]{32}$/i", $authCode))
177 'error' =>
'CALL_AUTH_FAILED',
178 'error_description' =>
'Call: user auth failed [code is not correct]',
183 if (!self::checkQueryMethod(array_merge(self::METHODS_WITH_AUTH, self::METHODS_WITHOUT_AUTH)))
186 'error' =>
'CALL_AUTH_METHOD_ERROR',
187 'error_description' =>
'Call: you don\'t have access to use this method [2]',
194 $xmlId = self::AUTH_TYPE.
"|".$authCode;
196 if ($USER->IsAuthorized())
198 if ($USER->GetParam(
'EXTERNAL_AUTH_ID') ==
'call')
200 if ($USER->GetParam(
'XML_ID') == $xmlId)
202 $res = self::getSuccessfulResult();
204 \CUser::SetLastActivityDate($USER->GetID(),
true);
211 'error' =>
'CALL_AUTH_DIFF_USER',
212 'error_description' =>
'Call: you are authorized with a different user [2]',
213 'additional' => [
'hash' => mb_substr($USER->GetParam(
'XML_ID'), mb_strlen(self::AUTH_TYPE) + 1)]
222 'error' =>
'CALL_AUTH_PORTAL_USER',
223 'error_description' =>
'Call: you are authorized with a portal user [2]',
231 $userData = \Bitrix\Main\UserTable::getList(
233 'select' => [
'ID',
'EXTERNAL_AUTH_ID'],
234 'filter' => [
'=XML_ID' => $xmlId]
238 if ($userData && $userData[
'EXTERNAL_AUTH_ID'] ==
'call')
242 $res = self::getSuccessfulResult();
244 \CUser::SetLastActivityDate($USER->GetID(),
true);
250 'error' =>
'CALL_AUTH_FAILED',
251 'error_description' =>
'Call: user auth failed [user not found]',
258 public static function authorizeById($userId, $setCookie =
null, $skipAuthorizeCheck =
false)
262 if (!$skipAuthorizeCheck && $USER->IsAuthorized())
267 $context = \Bitrix\Main\Context::getCurrent();
269 if (is_null($setCookie))
272 if ($context->getRequest()->getCookieRaw(
'BITRIX_CALL_AUTH'))
278 if ($USER->GetID() != $userId)
280 $USER->Authorize($userId, $setCookie, $setCookie,
'public');
283 $cookie = new \Bitrix\Main\Web\Cookie(
'BITRIX_CALL_AUTH',
'Y',
null,
false);
284 $cookie->setHttpOnly(
false);
285 $context->getResponse()->addCookie($cookie);
287 $authCode = str_replace(self::AUTH_TYPE.
'|',
'', $USER->GetParam(
'XML_ID'));
289 $cookie = new \Bitrix\Main\Web\Cookie(
'BITRIX_CALL_HASH', $authCode,
null,
false);
290 $cookie->setHttpOnly(
false);
291 $context->getResponse()->addCookie($cookie);
315 $method = mb_substr($method, 0, mb_strrpos($method,
'?'));