Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
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()
Definition
application.php:95
Bitrix\Main\Engine\ActionFilter\Authentication
Definition
authentication.php:14
Bitrix\Main\Engine\ActionFilter\Authentication\onBeforeAction
onBeforeAction(Event $event)
Definition
authentication.php:28
Bitrix\Main\Engine\ActionFilter\Authentication\ERROR_INVALID_AUTHENTICATION
const ERROR_INVALID_AUTHENTICATION
Definition
authentication.php:15
Bitrix\Main\Engine\ActionFilter\Authentication\__construct
__construct($enableRedirect=false)
Definition
authentication.php:22
Bitrix\Main\Engine\ActionFilter\Base
Definition
base.php:15
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Definition
base.php:80
Bitrix\Main\Engine\ActionFilter\Base\getAction
getAction()
Definition
base.php:48
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\EventResult
Definition
eventresult.php:5
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Context
Definition
culture.php:9
Bitrix\Main\Engine\ActionFilter
Definition
authentication.php:4
Bitrix
modules
main
lib
engine
actionfilter
authentication.php
Создано системой
1.10.0