N°5102 - Allow to send emails using GSuite SMTP and OAuth - Rework

This commit is contained in:
Eric Espie
2022-06-23 12:20:53 +02:00
parent 9f60f27636
commit 54eb9d081b
29 changed files with 188 additions and 324 deletions

View File

@@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProviderAbstract;
use Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProviderFactory;
class OAuthClientGoogle extends OAuthClient
{
@@ -72,16 +72,11 @@ class OAuthClientGoogle extends OAuthClient
{
$this->Set('provider', 'Google');
$this->Set('scope', 'EMail');
$this->Set('redirect_url', OAuthClientProviderAbstract::GetRedirectUri());
$this->Set('redirect_url', OAuthClientProviderFactory::GetRedirectUri());
parent::PrefillCreationForm($aContextParam);
}
public function GetDefaultMailServer()
{
return 'imap.gmail.com';
}
public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '')
{
if ($sAttCode == 'provider' || $sAttCode == 'scope' || $sAttCode == 'redirect_url') {
@@ -115,31 +110,21 @@ class OAuthClientGoogle extends OAuthClient
$this->Set('provider', 'Google');
}
if (empty($this->Get('redirect_url'))) {
$this->Set('redirect_url', OAuthClientProviderAbstract::GetRedirectUri());
$this->Set('redirect_url', OAuthClientProviderFactory::GetRedirectUri());
}
if (empty($this->Get('scope'))) {
$this->Set('scope', 'EMail');
}
}
public function GetDefaultMailServer()
{
return 'imap.gmail.com';
}
public function GetScope()
{
return 'https://mail.google.com/';
}
public function AfterInsert()
{
parent::AfterInsert();
$sClass = get_class($this);
$sId = $this->GetKey();
cmdbAbstractObject::SetSessionMessage(
$sClass,
$sId,
"$sClass:$sId:OAuthClientCreated",
Dict::S('itop-oauth-client:Message:OAuthClientCreated'),
'info',
100,
true
);
}
}