This commit is contained in:
the-djmaze 2024-07-15 14:42:02 +02:00
parent 2ea68e88b0
commit 3161961faa

View file

@ -12,9 +12,9 @@ use RainLoop\Providers\Storage\Enumerations\StorageType;
class LoginGMailPlugin extends \RainLoop\Plugins\AbstractPlugin class LoginGMailPlugin extends \RainLoop\Plugins\AbstractPlugin
{ {
const const
NAME = 'GMail OAuth2', NAME = 'Login GMail OAuth2',
VERSION = '2.36', VERSION = '2.37',
RELEASE = '2024-04-23', RELEASE = '2024-07-15',
REQUIRED = '2.36.1', REQUIRED = '2.36.1',
CATEGORY = 'Login', CATEGORY = 'Login',
DESCRIPTION = 'GMail IMAP, Sieve & SMTP login using RFC 7628 OAuth2'; DESCRIPTION = 'GMail IMAP, Sieve & SMTP login using RFC 7628 OAuth2';
@ -55,18 +55,18 @@ class LoginGMailPlugin extends \RainLoop\Plugins\AbstractPlugin
$oHttp = $oActions->Http(); $oHttp = $oActions->Http();
$oHttp->ServerNoCache(); $oHttp->ServerNoCache();
$uri = \preg_replace('/.LoginGMail.*$/D', '', $_SERVER['REQUEST_URI']);
try try
{ {
if (isset($_GET['error'])) { if (isset($_GET['error'])) {
throw new \RuntimeException($_GET['error']); throw new \RuntimeException($_GET['error']);
} }
if (!isset($_GET['code']) || empty($_GET['state']) || 'gmail' !== $_GET['state']) { if (isset($_GET['code']) && isset($_GET['state']) && 'gmail' === $_GET['state']) {
$oActions->Location(\RainLoop\Utils::WebPath()); $oGMail = $this->gmailConnector();
exit;
} }
$oGMail = $this->gmailConnector(); if (empty($oGMail)) {
if (!$oGMail) { $oActions->Location($uri);
$oActions->Location(\RainLoop\Utils::WebPath());
exit; exit;
} }
@ -137,7 +137,7 @@ class LoginGMailPlugin extends \RainLoop\Plugins\AbstractPlugin
{ {
$oActions->Logger()->WriteException($oException, \LOG_ERR); $oActions->Logger()->WriteException($oException, \LOG_ERR);
} }
$oActions->Location(\RainLoop\Utils::WebPath()); $oActions->Location($uri);
exit; exit;
} }