1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
AuthorizeUserCommandHandler.php
См. документацию.
1
<?php
2
3
declare(strict_types=1);
4
5
namespace
Bitrix\Rest\Public\Command\Auth;
6
7
use Bitrix\Main;
8
use Bitrix\Rest\Internal\Repository;
9
10
class
AuthorizeUserCommandHandler
11
{
12
protected
Repository\Auth\AuthorizationRepository
$repo
;
13
protected
bool
$needToLog
=
true
;
14
protected \CUser
$userAuthorizer
;
15
16
public
function
__construct
(
17
?
Repository
\
Auth
\AuthorizationRepository
$repo
=
null
,
18
?
bool
$needToLog
=
null
,
19
?\CUser
$userAuthorizer
=
null
,
20
)
21
{
22
$this->repo =
$repo
??
new
Repository\Auth\AuthorizationRepository
();
23
$this->needToLog =
$needToLog
??
Main\Config\Option::get
(
'main'
,
'event_log_login_success'
,
'N'
) ===
'Y'
;
24
if
(
$userAuthorizer
)
25
{
26
$this->userAuthorizer =
$userAuthorizer
;
27
}
28
else
29
{
30
global
$USER
;
31
32
if
(!is_object(
$USER
))
33
{
34
throw
new
Main\ObjectNotFoundException
(
'user object not found'
);
35
}
36
37
$this->userAuthorizer =
$USER
;
38
}
39
}
40
41
public
function
__invoke
(
AuthorizeUserCommand
$command): void
42
{
43
$userId
= $command->userId;
44
$applicationId = (int)$command->applicationId;
45
$currentHour = $command->timePeriod ??
new
Main\Type\DateTime
(date(
'Y-m-d H'
),
'Y-m-d H'
);
46
47
if
((
$userId <= 0 || $this->
userAuthorizer->Authorize(
$userId
,
false
,
false
, $applicationId)))
48
{
49
setSessionExpired
(
true
);
50
51
if
($this->needToLog)
52
{
53
$this->repo->saveAuthorization(
$userId
, $applicationId, $currentHour);
54
}
55
}
56
else
57
{
58
throw
new
Main\AccessDeniedException
();
59
}
60
}
61
}
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Main\AccessDeniedException
Определения
AccessDeniedException.php:9
Bitrix\Main\Config\Option\get
static get($moduleId, $name, $default="", $siteId=false)
Определения
option.php:30
Bitrix\Main\ObjectNotFoundException
Определения
ObjectNotFoundException.php:9
Bitrix\Main\Type\DateTime
Определения
datetime.php:9
Bitrix\Rest\Internal\Repository\Auth\AuthorizationRepository
Определения
AuthorizationRepository.php:12
Bitrix\Rest\Public\Command\Auth\AuthorizeUserCommandHandler
Определения
AuthorizeUserCommandHandler.php:11
Bitrix\Rest\Public\Command\Auth\AuthorizeUserCommandHandler\$needToLog
bool $needToLog
Определения
AuthorizeUserCommandHandler.php:13
Bitrix\Rest\Public\Command\Auth\AuthorizeUserCommandHandler\__invoke
__invoke(AuthorizeUserCommand $command)
Определения
AuthorizeUserCommandHandler.php:41
Bitrix\Rest\Public\Command\Auth\AuthorizeUserCommandHandler\__construct
__construct(?Repository\Auth\AuthorizationRepository $repo=null, ?bool $needToLog=null, ?\CUser $userAuthorizer=null,)
Определения
AuthorizeUserCommandHandler.php:16
Bitrix\Rest\Public\Command\Auth\AuthorizeUserCommandHandler\$userAuthorizer
CUser $userAuthorizer
Определения
AuthorizeUserCommandHandler.php:14
Bitrix\Rest\Public\Command\Auth\AuthorizeUserCommandHandler\$repo
Repository Auth AuthorizationRepository $repo
Определения
AuthorizeUserCommandHandler.php:12
Bitrix\Rest\Public\Command\Auth\AuthorizeUserCommand
Определения
AuthorizeUserCommand.php:10
$USER
global $USER
Определения
csv_new_run.php:40
setSessionExpired
setSessionExpired($pIsExpired=true)
Определения
tools.php:5130
Bitrix\Main\Repository
Bitrix\Rest\Internal\Repository\Auth
Определения
AuthorizationRepository.php:5
bitrix
modules
rest
lib
Public
Command
Auth
AuthorizeUserCommandHandler.php
Создано системой
1.14.0