diff --git a/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml b/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml
index 9303daa6b..a40a51436 100644
--- a/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml
+++ b/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml
@@ -37,6 +37,16 @@
false
+
+ true
+
+ active
+ inactive
+
+ status
+ inactive
+ false
+
description
@@ -101,7 +111,7 @@
if (!$bEditMode) {
$oConfig = utils::GetConfig();
$sScope = $this->Get('scope');
- if (empty($this->Get('token'))) {
+ if ($this->Get('status') == 'inactive') {
$oPage->p(''.Dict::S('itop-oauth-client:Message:MissingToken').'');
} elseif (($sScope == 'SMTP' || $sScope == 'EMail') && $oConfig->Get('email_transport_smtp.username') == $this->Get('name')) {
$sLabel = Dict::S('itop-oauth-client:UsedForSMTP');
@@ -111,6 +121,36 @@
}
}
}
+ ]]>
+
+
+ false
+ public
+ Overload-DBObject
+
+
+
+ false
+ public
+ Overload-DBObject
+
@@ -139,12 +179,15 @@
$this->Get('token'),
- 'expires_in' => date_format(new DateTime($this->Get('token_expiration')), 'U') - time(),
- 'refresh_token' => $this->Get('refresh_token'),
- 'token_type' => 'Bearer',
- ]);
+ if ($this->Get('status') == 'active') {
+ return new \League\OAuth2\Client\Token\AccessToken([
+ 'access_token' => $this->Get('token'),
+ 'expires_in' => date_format(new DateTime($this->Get('token_expiration')), 'U') - time(),
+ 'refresh_token' => $this->Get('refresh_token'),
+ 'token_type' => 'Bearer',
+ ]);
+ }
+ return null;
}
]]>
@@ -159,6 +202,7 @@
if (!empty($oAccessToken->getRefreshToken())) {
$this->Set('refresh_token', $oAccessToken->getRefreshToken());
}
+ $this->Set('status', 'active');
$this->DBUpdate();
}
]]>
@@ -190,6 +234,16 @@
+
+
+ -
+ 1
+
+ -
+ 3
+
+
+
-
diff --git a/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php b/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php
index fcf85741d..1a91fb173 100644
--- a/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php
+++ b/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php
@@ -35,6 +35,10 @@ Dict::Add('EN US', 'English', 'English', [
'Class:OAuthClient/Attribute:name+' => '',
'Class:OAuthClient/Attribute:scope' => 'Scope',
'Class:OAuthClient/Attribute:scope+' => '',
+ 'Class:OAuthClient/Attribute:status' => 'Status',
+ 'Class:OAuthClient/Attribute:status+' => '',
+ 'Class:OAuthClient/Attribute:status/Value:active' => 'Access token generated',
+ 'Class:OAuthClient/Attribute:status/Value:inactive' => 'No Access token',
'Class:OAuthClient/Attribute:description' => 'Description',
'Class:OAuthClient/Attribute:description+' => '',
'Class:OAuthClient/Attribute:client_id' => 'Client id',
diff --git a/datamodels/2.x/itop-oauth-client/src/Model/OAuthClientAzure.php b/datamodels/2.x/itop-oauth-client/src/Model/OAuthClientAzure.php
index 75d80a424..eb798e64d 100644
--- a/datamodels/2.x/itop-oauth-client/src/Model/OAuthClientAzure.php
+++ b/datamodels/2.x/itop-oauth-client/src/Model/OAuthClientAzure.php
@@ -50,20 +50,24 @@ class OAuthClientAzure extends OAuthClient
]));
MetaModel::Init_SetZListItems('details', [
- 0 => 'name',
- 1 => 'description',
- 2 => 'provider',
- 3 => 'scope',
- 4 => 'redirect_url',
- 5 => 'client_id',
- 6 => 'client_secret',
- 7 => 'mailbox_list',
+ 'name',
+ 'status',
+ 'description',
+ 'provider',
+ 'scope',
+ 'redirect_url',
+ 'client_id',
+ 'client_secret',
+ 'mailbox_list',
]);
MetaModel::Init_SetZListItems('standard_search', [
- 0 => 'name',
- 2 => 'provider',
+ 'name',
+ 'provider',
+ 'status',
]);
MetaModel::Init_SetZListItems('list', [
+ 'status',
+ 'provider',
]);
}
diff --git a/datamodels/2.x/itop-oauth-client/src/Model/OAuthClientGoogle.php b/datamodels/2.x/itop-oauth-client/src/Model/OAuthClientGoogle.php
index a03e4c3a7..83c111852 100644
--- a/datamodels/2.x/itop-oauth-client/src/Model/OAuthClientGoogle.php
+++ b/datamodels/2.x/itop-oauth-client/src/Model/OAuthClientGoogle.php
@@ -51,20 +51,24 @@ class OAuthClientGoogle extends OAuthClient
]));
MetaModel::Init_SetZListItems('details', [
- 0 => 'name',
- 1 => 'description',
- 2 => 'provider',
- 3 => 'scope',
- 4 => 'redirect_url',
- 5 => 'client_id',
- 6 => 'client_secret',
- 7 => 'mailbox_list',
+ 'name',
+ 'status',
+ 'description',
+ 'provider',
+ 'scope',
+ 'redirect_url',
+ 'client_id',
+ 'client_secret',
+ 'mailbox_list',
]);
MetaModel::Init_SetZListItems('standard_search', [
- 0 => 'name',
- 2 => 'provider',
+ 'name',
+ 'provider',
+ 'status',
]);
MetaModel::Init_SetZListItems('list', [
+ 'status',
+ 'provider',
]);
}