1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #5993 from turbo124/v5-develop

Gmail offline_access
This commit is contained in:
David Bomba 2021-06-10 17:17:15 +10:00 committed by GitHub
commit 0883e62c73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -491,23 +491,23 @@ class LoginController extends BaseController
{
//'https://www.googleapis.com/auth/gmail.send','email','profile','openid'
$scopes = [];
$parameters = [];
if($provider == 'google'){
$scopes = ['gmail.send','email','profile','openid'];
$scopes = ['https://www.googleapis.com/auth/gmail.send','email','profile','openid'];
$parameters = ['access_type' => 'offline', 'redirect_uri' => config('ninja.app_url')."/auth/google"];
}
if (request()->has('code')) {
return $this->handleProviderCallback($provider);
} else {
return Socialite::driver($provider)->with(['redirect_uri' => config('ninja.app_url')."/auth/google"])->scopes($scopes)->redirect();
return Socialite::driver($provider)->with($parameters)->scopes($scopes)->redirect();
}
}
public function handleProviderCallback(string $provider)
{
$socialite_user = Socialite::driver($provider)
->with(['redirect_uri' => config('ninja.app_url')."/auth/google"])
->user();
$socialite_user = Socialite::driver($provider)->user();
if($user = OAuth::handleAuth($socialite_user, $provider))
{