Appropriately refresh sending tokens

This commit is contained in:
David Bomba 2022-06-22 19:18:00 +10:00
parent 386c3bff0e
commit 5513422739

View File

@ -342,8 +342,9 @@ class NinjaMailerJob implements ShouldQueue
private function refreshOfficeToken($user) private function refreshOfficeToken($user)
{ {
$expiry = $user->oauth_user_token_expiry ?: now()->subDay();
if($user->oauth_user_token_expiry->lt(now())) if($expiry->lt(now()))
{ {
$guzzle = new \GuzzleHttp\Client(); $guzzle = new \GuzzleHttp\Client();
$url = 'https://login.microsoftonline.com/common/oauth2/v2.0/token'; $url = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';