1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
authentication.php
См. документацию.
1
<?php
2
3
4
namespace
Bitrix\Main\Engine\ActionFilter;
5
6
7
use Bitrix\Main\Context;
8
use Bitrix\Main\Error;
9
use Bitrix\Main\Event;
10
use Bitrix\Main\EventResult;
11
use Bitrix\Main\Localization\Loc;
12
13
final
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
{
37
LocalRedirect
(
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
}
Bitrix\Main\Application\getInstance
static getInstance()
Определения
application.php:98
Bitrix\Main\Engine\ActionFilter\Authentication\onBeforeAction
onBeforeAction(Event $event)
Определения
authentication.php:28
Bitrix\Main\Engine\ActionFilter\Authentication\ERROR_INVALID_AUTHENTICATION
const ERROR_INVALID_AUTHENTICATION
Определения
authentication.php:15
Bitrix\Main\Engine\ActionFilter\Authentication\__construct
__construct($enableRedirect=false)
Определения
authentication.php:22
Bitrix\Main\Engine\ActionFilter\Base
Определения
base.php:15
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Определения
base.php:80
Bitrix\Main\Engine\ActionFilter\Base\getAction
getAction()
Определения
base.php:48
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\Event
Определения
event.php:5
Bitrix\Main\EventResult
Определения
eventresult.php:5
$USER
global $USER
Определения
csv_new_run.php:40
SITE_DIR
const SITE_DIR(!defined('LANG'))
Определения
include.php:72
LocalRedirect
LocalRedirect($url, $skip_security_check=false, $status="302 Found")
Определения
tools.php:4005
Bitrix\Main\Authentication
Определения
application.php:9
Bitrix\Main
Bitrix
$event
$event
Определения
prolog_after.php:141
bitrix
modules
main
lib
engine
actionfilter
authentication.php
Создано системой
1.14.0