Skip to content

Commit

Permalink
feat: support setting hosted domain for google provider (#70)
Browse files Browse the repository at this point in the history
* feat: support setting hosted domain for google provider

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
imorland and StyleCIBot authored Dec 4, 2023
1 parent 1359804 commit c93ca9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions resources/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
14 changes: 13 additions & 1 deletion src/Providers/Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function fields(): array
return [
'client_id' => 'required',
'client_secret' => 'required',
'hosted_domain' => '',
];
}

Expand All @@ -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());
Expand Down

0 comments on commit c93ca9e

Please sign in to comment.