7a137 google auth (#520)
* google oauth * fix lint * cleanup debug * Oauth changes, alert message, email validation * fix exception and inline return condition * fix google oauth * UI fixes * fix provider user --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
@@ -7,5 +7,7 @@ use Laravel\Socialite\Contracts\User;
|
||||
interface OAuthDriver
|
||||
{
|
||||
public function getRedirectUrl(): string;
|
||||
public function setRedirectUrl($url): self;
|
||||
public function getUser(): User;
|
||||
public function canCreateUser(): bool;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ use Laravel\Socialite\Two\GoogleProvider;
|
||||
|
||||
class OAuthGoogleDriver implements OAuthDriver
|
||||
{
|
||||
private ?string $redirectUrl = null;
|
||||
|
||||
protected GoogleProvider $provider;
|
||||
|
||||
public function __construct()
|
||||
@@ -22,6 +24,7 @@ class OAuthGoogleDriver implements OAuthDriver
|
||||
return $this->provider
|
||||
->scopes([Sheets::DRIVE_FILE])
|
||||
->stateless()
|
||||
->redirectUrl($this->redirectUrl ?? config('services.google.redirect'))
|
||||
->with([
|
||||
'access_type' => 'offline',
|
||||
'prompt' => 'consent select_account'
|
||||
@@ -34,6 +37,19 @@ class OAuthGoogleDriver implements OAuthDriver
|
||||
{
|
||||
return $this->provider
|
||||
->stateless()
|
||||
->redirectUrl($this->redirectUrl ?? config('services.google.redirect'))
|
||||
->user();
|
||||
}
|
||||
|
||||
public function canCreateUser(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setRedirectUrl($url): OAuthDriver
|
||||
{
|
||||
$this->redirectUrl = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user