diff --git a/resources/locale/en.yml b/resources/locale/en.yml index 89126d3..a3ae6f8 100644 --- a/resources/locale/en.yml +++ b/resources/locale/en.yml @@ -58,6 +58,7 @@ fof-oauth: client_id_label: => fof-oauth.ref.settings.client_id client_secret_label: => fof-oauth.ref.settings.client_secret + hosted_domain_label: Hosted Domain (G suite/Google Apps for Business, optional) linkedin: description: Create an application at {link}. diff --git a/src/Providers/Google.php b/src/Providers/Google.php index 5da27d3..2ebdbcf 100644 --- a/src/Providers/Google.php +++ b/src/Providers/Google.php @@ -33,6 +33,7 @@ public function fields(): array return [ 'client_id' => 'required', 'client_secret' => 'required', + 'hosted_domain' => '', ]; } @@ -43,11 +44,22 @@ public function provider(string $redirectUri): AbstractProvider 'clientSecret' => $this->getSetting('client_secret'), 'redirectUri' => $redirectUri, 'approvalPrompt' => 'force', - 'hostedDomain' => null, + 'hostedDomain' => $this->getHostedDomain(), 'accessType' => 'offline', ]); } + /** + * @return string|null + */ + protected function getHostedDomain() + { + $hostedDomain = $this->getSetting('hosted_domain'); + + // Return null if $hostedDomain is an empty string + return $hostedDomain !== '' ? $hostedDomain : null; + } + public function suggestions(Registration $registration, $user, string $token) { $this->verifyEmail($email = $user->getEmail());