1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Ninja/OAuth/OAuth.php
David Bomba 9ff1817c1c Google Auth - Authenticate with backend server (API) (#1405)
* Google OAuth - Authentication with a backend server
2017-03-31 00:01:42 +11:00

44 lines
783 B
PHP

<?php namespace App\Ninja\OAuth;
use App\Models\User;
class OAuth {
private $providerInstance;
public function __construct()
{
}
public function getProvider($provider)
{
switch ($provider)
{
case 'google';
$this->providerInstance = new Providers\Google();
return $this;
default:
return null;
break;
}
}
public function getTokenResponse($token)
{
$email = null;
$user = null;
if($this->providerInstance)
$user = User::where('email', $this->providerInstance->getTokenResponse($token))->first();
if ($user)
return $user;
else
return false;
}
}
?>