mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
N°5102 - Allow to send emails using GSuite SMTP and OAuth - Rework
This commit is contained in:
@@ -4,27 +4,30 @@ namespace Combodo\iTop\Core\Authentication\Client\OAuth;
|
||||
|
||||
use League\OAuth2\Client\Provider\GenericProvider;
|
||||
use League\OAuth2\Client\Token\AccessToken;
|
||||
use utils;
|
||||
use OAuthClient;
|
||||
|
||||
abstract class OAuthClientProviderAbstract implements IOAuthClientProvider
|
||||
{
|
||||
/** @var string */
|
||||
static protected $sVendorName = '';
|
||||
/** @var array */
|
||||
static protected $sVendorColors = ['', '', '', ''];
|
||||
/** @var string */
|
||||
static protected $sVendorIcon = '';
|
||||
static protected $sRedirectUri = '';
|
||||
static protected $sRequiredSMTPScope = '';
|
||||
static protected $sRequiredIMAPScope = '';
|
||||
static protected $sRequiredPOPScope = '';
|
||||
// /** @var string */
|
||||
// static protected $sVendorName = '';
|
||||
// /** @var array */
|
||||
// static protected $sVendorColors = ['', '', '', ''];
|
||||
// /** @var string */
|
||||
// static protected $sVendorIcon = '';
|
||||
// static protected $sRequiredSMTPScope = '';
|
||||
// static protected $sRequiredIMAPScope = '';
|
||||
// static protected $sRequiredPOPScope = '';
|
||||
|
||||
/** @var \League\OAuth2\Client\Provider\GenericProvider */
|
||||
protected $oVendorProvider;
|
||||
/** @var \League\OAuth2\Client\Token\AccessToken */
|
||||
protected $oAccessToken;
|
||||
|
||||
protected $sScope;
|
||||
/** @var OAuthClient */
|
||||
protected $oOauthClient;
|
||||
|
||||
public function __construct($oOauthClient)
|
||||
{
|
||||
$this->oOauthClient = $oOauthClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \League\OAuth2\Client\Provider\GenericProvider
|
||||
@@ -47,7 +50,7 @@ abstract class OAuthClientProviderAbstract implements IOAuthClientProvider
|
||||
*/
|
||||
public function GetAccessToken(): AccessToken
|
||||
{
|
||||
return $this->oAccessToken;
|
||||
return $this->oOauthClient->GetAccessToken();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,60 +58,7 @@ abstract class OAuthClientProviderAbstract implements IOAuthClientProvider
|
||||
*/
|
||||
public function SetAccessToken(AccessToken $oAccessToken)
|
||||
{
|
||||
$this->oAccessToken = $oAccessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function GetVendorName(): string
|
||||
{
|
||||
return static::$sVendorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function InitizalizeRedirectUri()
|
||||
{
|
||||
static::$sRedirectUri = utils::GetAbsoluteUrlAppRoot().'pages/oauth.landing.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function GetRedirectUri(): string
|
||||
{
|
||||
if (static::$sRedirectUri === '') {
|
||||
static::InitizalizeRedirectUri();
|
||||
}
|
||||
|
||||
return static::$sRedirectUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function GetRequiredSMTPScope(): string
|
||||
{
|
||||
return static::$sRequiredSMTPScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function GetRequiredIMAPScope(): string
|
||||
{
|
||||
return static::$sRequiredIMAPScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function GetRequiredPOPScope(): string
|
||||
{
|
||||
return static::$sRequiredPOPScope;
|
||||
$this->oOauthClient->SetAccessToken($oAccessToken);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,15 +66,7 @@ abstract class OAuthClientProviderAbstract implements IOAuthClientProvider
|
||||
*/
|
||||
public function GetScope()
|
||||
{
|
||||
return $this->sScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $sScope
|
||||
*/
|
||||
public function SetScope($sScope)
|
||||
{
|
||||
$this->sScope = $sScope;
|
||||
return $this->oOauthClient->GetScope();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user