1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AuthorizeUserCommandHandler.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Rest\Public\Command\Auth;
6
7use Bitrix\Main;
8use Bitrix\Rest\Internal\Repository;
9
11{
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 {
23 $this->needToLog = $needToLog ?? Main\Config\Option::get('main', 'event_log_login_success', 'N') === 'Y';
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 {
50
51 if ($this->needToLog)
52 {
53 $this->repo->saveAuthorization($userId, $applicationId, $currentHour);
54 }
55 }
56 else
57 {
59 }
60 }
61}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static get($moduleId, $name, $default="", $siteId=false)
Определения option.php:30
__construct(?Repository\Auth\AuthorizationRepository $repo=null, ?bool $needToLog=null, ?\CUser $userAuthorizer=null,)
Определения AuthorizeUserCommandHandler.php:16
Repository Auth AuthorizationRepository $repo
Определения AuthorizeUserCommandHandler.php:12
global $USER
Определения csv_new_run.php:40
setSessionExpired($pIsExpired=true)
Определения tools.php:5130