mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6109 from turbo124/v5-develop
Refresh gmail tokens prior to emailing events
This commit is contained in:
commit
314cebb99e
@ -178,7 +178,14 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
$google = (new Google())->init();
|
$google = (new Google())->init();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
if ($google->getClient()->isAccessTokenExpired()) {
|
||||||
|
$google->refreshToken($user);
|
||||||
|
$user = $user->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
$google->getClient()->setAccessToken(json_encode($user->oauth_user_token));
|
$google->getClient()->setAccessToken(json_encode($user->oauth_user_token));
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(\Exception $e) {
|
catch(\Exception $e) {
|
||||||
$this->logMailError('Gmail Token Invalid', $this->company->clients()->first());
|
$this->logMailError('Gmail Token Invalid', $this->company->clients()->first());
|
||||||
@ -186,9 +193,7 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
return $this->setMailDriver();
|
return $this->setMailDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($google->getClient()->isAccessTokenExpired()) {
|
|
||||||
$google->refreshToken($user);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now that our token is refreshed and valid we can boot the
|
* Now that our token is refreshed and valid we can boot the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user