1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
authentication.php
См. документацию.
1<?php
2
3
4namespace Bitrix\Main\Engine\ActionFilter;
5
6
7use Bitrix\Main\Context;
8use Bitrix\Main\Error;
9use Bitrix\Main\Event;
10use Bitrix\Main\EventResult;
11use Bitrix\Main\Localization\Loc;
12
13final class Authentication extends Base
14{
15 const ERROR_INVALID_AUTHENTICATION = 'invalid_authentication';
16
20 private $enableRedirect;
21
22 public function __construct($enableRedirect = false)
23 {
24 $this->enableRedirect = $enableRedirect;
25 parent::__construct();
26 }
27
28 public function onBeforeAction(Event $event)
29 {
30 global $USER;
31
32 if (!($USER instanceof \CUser) || !$USER->getId())
33 {
34 $isAjax = $this->getAction()->getController()->getRequest()->getHeader('BX-Ajax');
35 if ($this->enableRedirect && !$isAjax)
36 {
38 SITE_DIR .
39 'auth/?backurl=' .
40 urlencode(\Bitrix\Main\Application::getInstance()->getContext()->getRequest()->getRequestUri())
41 );
42
43 return new EventResult(EventResult::ERROR, null, null, $this);
44 }
45
46 Context::getCurrent()->getResponse()->setStatus(401);
47 $this->addError(new Error(
48 Loc::getMessage("MAIN_ENGINE_FILTER_AUTHENTICATION_ERROR"), self::ERROR_INVALID_AUTHENTICATION)
49 );
50
51 return new EventResult(EventResult::ERROR, null, null, $this);
52 }
53
54 return null;
55 }
56}
static getInstance()
Определения application.php:98
__construct($enableRedirect=false)
Определения authentication.php:22
addError(Error $error)
Определения base.php:80
Определения error.php:15
Определения event.php:5
global $USER
Определения csv_new_run.php:40
const SITE_DIR(!defined('LANG'))
Определения include.php:72
LocalRedirect($url, $skip_security_check=false, $status="302 Found")
Определения tools.php:4005
$event
Определения prolog_after.php:141