Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
application.php
1
<?php
9
namespace
Bitrix\Rest\APAuth
;
10
11
use
Bitrix\Main\Authentication\ApplicationPasswordTable
;
12
use
Bitrix\Main\Localization\Loc
;
13
use
Bitrix\Main\Type\DateTime
;
14
15
Loc::loadMessages
(__FILE__);
16
22
class
Application
extends
\Bitrix\Main\Authentication\Application
23
{
24
const
ID
=
'rest'
;
25
26
protected
$validUrls
= array(
27
"/rest/"
,
28
);
29
30
public
static
function
onApplicationsBuildList
()
31
{
32
return
array(
33
"ID"
=> static::ID,
34
"NAME"
=>
Loc::getMessage
(
"REST_APP_TITLE"
),
35
"DESCRIPTION"
=>
Loc::getMessage
(
"REST_APP_DESC"
),
36
"SORT"
=> 1000,
37
"CLASS"
=> __CLASS__,
38
"VISIBLE"
=>
false
,
39
);
40
}
41
50
public
static
function
generateAppPassword
($siteTitle, array $scopeList)
51
{
52
global $USER;
53
54
$password = ApplicationPasswordTable::generatePassword();
55
56
$res = ApplicationPasswordTable::add(array(
57
'USER_ID'
=> $USER->getID(),
58
'APPLICATION_ID'
=> static::ID,
59
'PASSWORD'
=> $password,
60
'DATE_CREATE'
=>
new
DateTime
(),
61
'COMMENT'
=>
Loc::getMessage
(
'REST_APP_COMMENT'
),
62
'SYSCOMMENT'
=>
Loc::getMessage
(
'REST_APP_SYSCOMMENT'
, array(
63
'#TITLE#'
=> $siteTitle,
64
)),
65
));
66
67
if
($res->isSuccess())
68
{
69
$scopeList = array_unique($scopeList);
70
foreach
($scopeList as $scope)
71
{
72
PermissionTable::add(array(
73
'PASSWORD_ID'
=> $res->getId(),
74
'PERM'
=> $scope,
75
));
76
}
77
78
return
$password;
79
}
80
81
return
false
;
82
}
83
}
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Authentication\ApplicationPasswordTable
Definition
applicationpassword.php:32
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Rest\APAuth\Application\ID
const ID
Definition
application.php:24
Bitrix\Rest\APAuth\Application\generateAppPassword
static generateAppPassword($siteTitle, array $scopeList)
Definition
application.php:50
Bitrix\Rest\APAuth\Application\$validUrls
$validUrls
Definition
application.php:26
Bitrix\Rest\APAuth\Application\onApplicationsBuildList
static onApplicationsBuildList()
Definition
application.php:30
Bitrix\Rest\APAuth
Definition
application.php:9
modules
rest
lib
apauth
application.php
Создано системой
1.10.0