- Модуль: rest
- Путь к файлу: ~/bitrix/modules/rest/lib/apauth/auth.php
- Класс: Bitrix\Rest\APAuth\Auth
- Вызов: Auth::check
static function check($auth, $scope)
{
$result = array('error' => 'INVALID_CREDENTIALS', 'error_description' => 'Invalid request credentials');
$uid = $auth[static::$authQueryParams['UID']];
if(strval(intval($uid)) === $uid)
{
$userInfo = array('ID' => intval($uid));
}
else
{
$dbRes = UserTable::getList(array(
'filter' => array(
'=LOGIN' => $uid,
'=ACTIVE' => 'Y',
),
'select' => array('ID'),
));
$userInfo = $dbRes->fetch();
}
if($userInfo)
{
$dbRes = PasswordTable::getList(array(
'filter' => array(
'=USER_ID' => $userInfo['ID'],
'=PASSWORD' => $auth[static::$authQueryParams['PASSWORD']],
'=ACTIVE' => PasswordTable::ACTIVE,
),
'select' => array('ID')
));
$passwordInfo = $dbRes->fetch();
if(!$passwordInfo)
{
$passwordInfo = static::checkOldPassword($userInfo['ID'], $auth[static::$authQueryParams['PASSWORD']]);
}
if($passwordInfo)
{
if(static::checkPermission($passwordInfo["ID"], $scope) === true)
{
$result = array(
'user_id' => $userInfo["ID"],
'password_id' => $passwordInfo["ID"],
);
}
else
{
$result = array('error' => 'insufficient_scope', 'error_description' => 'The request requires higher privileges than provided by the webhook token');
}
}
}
return $result;
}