This commit is contained in:
Maxime Renou 2020-05-12 13:00:14 +02:00
parent 133aaff3e7
commit fedd615ed5
4 changed files with 45 additions and 9 deletions

View File

@ -10,12 +10,12 @@ return [
/**
* Route that redirects to Bluesquare Connect
*/
'login_url' => '/oauth/authorize',
'login_url' => '/connect/authorize',
/**
* OAuth callback URL
*/
'redirect_url' => env('BCONNECT_REDIRECT', 'http://localhost:8000/oauth/callback'),
'redirect_url' => env('BCONNECT_REDIRECT', 'http://localhost:8000/connect/callback'),
/**
* OAuth client id
@ -30,8 +30,8 @@ return [
/**
* OAuth scopes (separated with commas)
*/
'user_scopes' => '*',
'client_scopes' => '*',
'user_scopes' => env('BCONNECT_USER_SCOPES', '*'),
'client_scopes' => env('BCONNECT_CLIENT_SCOPES', '*'),
/**
* Bluesquare Connect URL

View File

@ -7,6 +7,7 @@ use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Psr\Http\Message\StreamInterface;
@ -361,8 +362,20 @@ class Connect
return config('bconnect.url') ?? 'https://connect.bluesquare.io';
}
public function routes(Router $router)
public function routes()
{
dump($router);
Route::middleware('web')
->namespace('Bluesquare\Connect\Controllers')
->group(function () {
Route::get('connect/authorize', 'ConnectController@authorize');
Route::get('connect/callback', 'ConnectController@callback');
});
Route::prefix('api')
->middleware('api')
->namespace('Bluesquare\Connect\Controllers')
->group(function () {
Route::post('connect/webhook', 'ConnectController@webhook');
});
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Bluesquare\Connect\Controllers;
use Bluesquare\Connect\Connect;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class ConnectController extends Controller
{
public function authorize(Connect $connect)
{
return $connect->redirect();
}
public function callback(Request $request, Connect $connect)
{
return $connect->loginFromCallback($request);
}
public function webhook(Request $request, Connect $connect)
{
return $connect->handleWebhook($request);
}
}

View File

@ -12,8 +12,6 @@ class Connect extends Facade
*/
public static function routes()
{
static::$app->make(\Bluesquare\Connect\Connect::class)->routes(
static::$app->make('router')
);
static::$app->make(\Bluesquare\Connect\Connect::class)->routes();
}
}