mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-06 03:02:34 +01:00
Minor fixes for Gmail API (#3125)
This commit is contained in:
parent
1b6ec9699a
commit
a2cf42766d
@ -15,6 +15,7 @@ use App\Libraries\MultiDB;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Dacastro4\LaravelGmail\Services\Message\Mail;
|
use Dacastro4\LaravelGmail\Services\Message\Mail;
|
||||||
use Illuminate\Mail\Transport\Transport;
|
use Illuminate\Mail\Transport\Transport;
|
||||||
|
use Swift_Mime_SimpleMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GmailTransport
|
* GmailTransport
|
||||||
@ -42,7 +43,7 @@ class GmailTransport extends Transport
|
|||||||
public function __construct(Mail $gmail, string $token)
|
public function __construct(Mail $gmail, string $token)
|
||||||
{
|
{
|
||||||
$this->gmail = $gmail;
|
$this->gmail = $gmail;
|
||||||
$this->token = $token
|
$this->token = $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -54,8 +55,8 @@ class GmailTransport extends Transport
|
|||||||
$this->gmail->to($message->getTo());
|
$this->gmail->to($message->getTo());
|
||||||
$this->gmail->from($message->getFrom());
|
$this->gmail->from($message->getFrom());
|
||||||
$this->gmail->subject($message->getSubject());
|
$this->gmail->subject($message->getSubject());
|
||||||
//$this->gmail->message($message->getBody());
|
$this->gmail->message($message->getBody());
|
||||||
$this->gmail->message($message->toString());
|
//$this->gmail->message($message->toString());
|
||||||
$this->gmail->cc($message->getCc());
|
$this->gmail->cc($message->getCc());
|
||||||
$this->gmail->bcc($message->getBcc());
|
$this->gmail->bcc($message->getBcc());
|
||||||
|
|
||||||
@ -65,3 +66,4 @@ class GmailTransport extends Transport
|
|||||||
|
|
||||||
return $this->numberOfRecipients($message);
|
return $this->numberOfRecipients($message);
|
||||||
}
|
}
|
||||||
|
}
|
@ -12,10 +12,12 @@
|
|||||||
namespace App\Helpers\Mail;
|
namespace App\Helpers\Mail;
|
||||||
|
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Mail\SupportMessageSent;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Providers\MailServiceProvider;
|
use App\Providers\MailServiceProvider;
|
||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Laravel\Socialite\Facades\Socialite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GmailTransportConfig
|
* GmailTransportConfig
|
||||||
@ -31,6 +33,10 @@ class GmailTransportConfig
|
|||||||
];
|
];
|
||||||
|
|
||||||
$user = MultiDB::hasUser($query);
|
$user = MultiDB::hasUser($query);
|
||||||
|
// $oauth_user = Socialite::driver('google')->stateless()->userFromToken($user->oauth_user_token);
|
||||||
|
|
||||||
|
// $user->oauth_user_token = $oauth_user->refreshToken;
|
||||||
|
// $user->save();
|
||||||
|
|
||||||
Config::set('mail.driver', 'gmail');
|
Config::set('mail.driver', 'gmail');
|
||||||
Config::set('services.gmail.token', $user->oauth_user_token);
|
Config::set('services.gmail.token', $user->oauth_user_token);
|
||||||
|
@ -11,8 +11,9 @@ class GmailTransportManager extends TransportManager
|
|||||||
protected function createGmailDriver()
|
protected function createGmailDriver()
|
||||||
{
|
{
|
||||||
$token = $this->app['config']->get('services.gmail.token', []);
|
$token = $this->app['config']->get('services.gmail.token', []);
|
||||||
|
$mail = new Mail;
|
||||||
|
|
||||||
return new GmailTransport(Mail $mail, string $token);
|
return new GmailTransport($mail, string $token);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -280,7 +280,7 @@ class LoginController extends BaseController
|
|||||||
/* Handle existing users who attempt to create another account with existing OAuth credentials */
|
/* Handle existing users who attempt to create another account with existing OAuth credentials */
|
||||||
if($user = OAuth::handleAuth($socialite_user, $provider))
|
if($user = OAuth::handleAuth($socialite_user, $provider))
|
||||||
{
|
{
|
||||||
$user->oauth_user_token = $socialite_user->token;
|
$user->oauth_user_token = $socialite_user->refreshToken;
|
||||||
$user->save();
|
$user->save();
|
||||||
Auth::login($user, true);
|
Auth::login($user, true);
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ class LoginController extends BaseController
|
|||||||
'password' => '',
|
'password' => '',
|
||||||
'email' => $socialite_user->getEmail(),
|
'email' => $socialite_user->getEmail(),
|
||||||
'oauth_user_id' => $socialite_user->getId(),
|
'oauth_user_id' => $socialite_user->getId(),
|
||||||
'oauth_user_token' => $socialite_user->token,
|
'oauth_user_token' => $socialite_user->refreshToken,
|
||||||
'oauth_provider_id' => $provider
|
'oauth_provider_id' => $provider
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user