1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
authtype.php
См. документацию.
1<?php
2
4
9
14class AuthType extends Base
15{
16 public const PASSWORD = 0b00000001;
17 public const APPLICATION = 0b00000010;
18 public const SESSION = 0b00000100;
19
20 public const ALL = self::APPLICATION | self::PASSWORD | self::SESSION;
21
22 public const ERROR_INSUFFICIENT_AUTH_TYPE = 'insufficient_auth_type';
23
24 private $types;
25
26 public function __construct($types)
27 {
28 $this->types = $types;
29 parent::__construct();
30 }
31
32 public function onBeforeAction(Event $event)
33 {
34 $scope = $this->getCurrentAuthType();
35 if (($this->types & $scope) === $scope)
36 {
37 return null;
38 }
39
40 $this->addError(new Error('The request requires higher privileges than provided.', self::ERROR_INSUFFICIENT_AUTH_TYPE));
41
42 return new EventResult(EventResult::ERROR, null, null, $this);
43 }
44
45 protected function getCurrentAuthType() : ?int
46 {
47 $server = $this->getRestServer();
48 if ($server)
49 {
50 switch ($server->getAuthType())
51 {
53 return static::PASSWORD;
55 return static::APPLICATION;
57 return static::SESSION;
58 }
59 }
60
61 return null;
62 }
63}
addError(Error $error)
Определения base.php:80
Определения error.php:15
Определения event.php:5
const AUTH_TYPE
Определения auth.php:23
onBeforeAction(Event $event)
Определения authtype.php:32
const ERROR_INSUFFICIENT_AUTH_TYPE
Определения authtype.php:22
const AUTH_TYPE
Определения auth.php:25
const AUTH_TYPE
Определения auth.php:18
Определения buffer.php:3
Определения accessexception.php:2
$event
Определения prolog_after.php:141